├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── LICENSE ├── README.md ├── board-manager ├── .gitignore ├── Makefile ├── Makefile.core ├── Makefile.sdcc ├── Makefile.tools ├── README.md ├── assemble.sh ├── gen_arduino_package_file.sh ├── gen_platform_entry.sh ├── gen_tools_entry.sh ├── minimize-sdcc.sh ├── package_template.json └── parts │ ├── platform-entry-sduino-0.3.0.txt │ ├── platform-entry-sduino-0.3.1.txt │ ├── platform-entry-sduino-0.3.2.txt │ ├── platform-entry-sduino-0.3.3.txt │ ├── platform-entry-sduino-0.4.0.txt │ ├── platform-entry-sduino-0.5-pre2.txt │ ├── platform-entry-sduino-0.5.txt │ ├── tools-entry-sdcc-10088.txt │ ├── tools-entry-sdcc-10738.txt │ ├── tools-entry-sdcc-11242.txt │ ├── tools-entry-sduino-tools-2017.10.21.txt │ ├── tools-entry-sduino-tools-2017.11.06.txt │ ├── tools-entry-sduino-tools-2017.11.13.txt │ ├── tools-entry-sduino-tools-2018.12.07.txt │ └── tools-entry-sduino-tools-2019.02.05.txt ├── docs ├── about.md ├── api │ ├── EEPROM.md │ ├── EEPROM │ │ └── examples │ │ │ ├── eeprom_get.md │ │ │ ├── eeprom_put.md │ │ │ ├── eeprom_read.md │ │ │ ├── eeprom_update.md │ │ │ └── eeprom_write.md │ ├── HardwareSerial.md │ ├── I2C.md │ ├── LiquidCrystal.md │ ├── LiquidCrystal_I2C.md │ ├── LiquidCrystal_pcf2119.md │ ├── Mini_SSD1306.md │ ├── PCD8544.md │ ├── Print.md │ ├── SPI.md │ ├── Servo.md │ ├── Stepper.md │ ├── Wire.md │ ├── migration.md │ └── oled-ssd1306.jpg ├── contact.md ├── developer │ ├── bare-metal-programming.md │ ├── coding-style.md │ ├── compiling-the-tools.md │ ├── cross-compile-for-osx.md │ ├── ide-integration.md │ ├── links.md │ ├── macro.md │ ├── optimizations.md │ ├── performance.md │ ├── pin_mapping.md │ ├── sdcc.md │ ├── spl.md │ └── update-to-manual.md ├── hardware │ ├── ST-LinkV2_pinout_01.jpg │ ├── bad-etching.jpg │ ├── esp14.md │ ├── esp14.png │ ├── esp14.svg │ ├── flashtool.md │ ├── st-link-v2-dongle.png │ ├── st-link_v2_baite.pdf │ ├── st-link_v2_baite.svg │ ├── stm8blue-pinout.png │ ├── stm8blue-pinout.svg │ ├── stm8blue-schematic.png │ ├── stm8blue.jpg │ ├── stm8blue.md │ ├── stm8s003.md │ ├── stm8sblack-pinout.png │ ├── stm8sblack-pinout.svg │ ├── stm8sblack-schematic.jpg │ ├── stm8sblack.jpg │ ├── stm8sblack.md │ ├── stm8sdiscovery.md │ └── w1209-thermostat.md ├── img │ ├── no-espstlink-10810e88.patch │ └── no-spi.patch ├── index.md └── usage │ ├── board-manager-install.md │ ├── build-cli.md │ ├── build-ide.md │ ├── faq.md │ ├── interrupts.md │ ├── limitations.md │ ├── manual-install.md │ ├── status-todo.md │ └── why-stm8.md ├── examples ├── blink-spl │ ├── Makefile │ ├── README.md │ ├── blink_spl.c │ ├── stm8s_conf.h │ └── stm8s_it.h ├── fade-all-pins │ ├── Makefile │ └── fade-all-pins.c ├── ping-hc04 │ ├── Makefile │ ├── ping-hc04.c │ └── ping-hc04.txt ├── sdcc-examples-stm8 │ ├── Makefile │ ├── README.md │ ├── blinky.c │ ├── stm8l.h │ ├── stm8s.h │ └── uart.c ├── uart-int │ ├── Makefile │ ├── README.md │ ├── stm8s_conf.h │ ├── stm8s_it.h │ └── uart-int.c ├── uart-ringbuffer │ ├── Makefile │ ├── README.md │ ├── stm8s_conf.h │ ├── stm8s_it.h │ ├── uart-ringbuffer.c │ └── uart-ringbuffer.h └── uart-spl │ ├── Makefile │ ├── README.md │ ├── stm8s_conf.h │ ├── stm8s_it.h │ └── uart_spl.c ├── mkdocs.yml ├── package_sduino_stm8_index.json ├── sduino ├── lib │ └── version.txt ├── stm8 │ ├── Arduino.mk │ ├── Common.mk │ ├── STM8S_StdPeriph_Driver │ │ ├── README.md │ │ ├── Release_Notes.html │ │ ├── inc │ │ │ ├── stm8s.h │ │ │ ├── stm8s_adc1.h │ │ │ ├── stm8s_adc2.h │ │ │ ├── stm8s_awu.h │ │ │ ├── stm8s_beep.h │ │ │ ├── stm8s_can.h │ │ │ ├── stm8s_clk.h │ │ │ ├── stm8s_conf.h │ │ │ ├── stm8s_exti.h │ │ │ ├── stm8s_flash.h │ │ │ ├── stm8s_gpio.h │ │ │ ├── stm8s_i2c.h │ │ │ ├── stm8s_itc.h │ │ │ ├── stm8s_iwdg.h │ │ │ ├── stm8s_rst.h │ │ │ ├── stm8s_spi.h │ │ │ ├── stm8s_tim1.h │ │ │ ├── stm8s_tim2.h │ │ │ ├── stm8s_tim3.h │ │ │ ├── stm8s_tim4.h │ │ │ ├── stm8s_tim5.h │ │ │ ├── stm8s_tim6.h │ │ │ ├── stm8s_uart1.h │ │ │ ├── stm8s_uart2.h │ │ │ ├── stm8s_uart3.h │ │ │ ├── stm8s_uart4.h │ │ │ └── stm8s_wwdg.h │ │ ├── lib │ │ │ ├── STM8AF52Ax.lib │ │ │ ├── STM8AF622x.lib │ │ │ ├── STM8AF626x.lib │ │ │ ├── STM8AF62Ax.lib │ │ │ ├── STM8S001.lib │ │ │ ├── STM8S003.lib │ │ │ ├── STM8S005.lib │ │ │ ├── STM8S007.lib │ │ │ ├── STM8S103.lib │ │ │ ├── STM8S105.lib │ │ │ ├── STM8S207.lib │ │ │ ├── STM8S208.lib │ │ │ └── STM8S903.lib │ │ ├── peripherie.ods │ │ ├── peripherie.png │ │ └── src │ │ │ ├── stm8s_adc1.c │ │ │ ├── stm8s_adc2.c │ │ │ ├── stm8s_awu.c │ │ │ ├── stm8s_beep.c │ │ │ ├── stm8s_can.c │ │ │ ├── stm8s_clk.c │ │ │ ├── stm8s_exti.c │ │ │ ├── stm8s_flash.c │ │ │ ├── stm8s_gpio.c │ │ │ ├── stm8s_i2c.c │ │ │ ├── stm8s_itc.c │ │ │ ├── stm8s_iwdg.c │ │ │ ├── stm8s_rst.c │ │ │ ├── stm8s_spi.c │ │ │ ├── stm8s_tim1.c │ │ │ ├── stm8s_tim2.c │ │ │ ├── stm8s_tim3.c │ │ │ ├── stm8s_tim4.c │ │ │ ├── stm8s_tim5.c │ │ │ ├── stm8s_tim6.c │ │ │ ├── stm8s_uart1.c │ │ │ ├── stm8s_uart2.c │ │ │ ├── stm8s_uart3.c │ │ │ ├── stm8s_uart4.c │ │ │ └── stm8s_wwdg.c │ ├── boards.txt │ ├── cores │ │ └── sduino │ │ │ ├── Arduino.h │ │ │ ├── HardwareSerial.c-1.c │ │ │ ├── HardwareSerial.c-10.c │ │ │ ├── HardwareSerial.c-2.c │ │ │ ├── HardwareSerial.c-3.c │ │ │ ├── HardwareSerial.c-4.c │ │ │ ├── HardwareSerial.c-5.c │ │ │ ├── HardwareSerial.c-6.c │ │ │ ├── HardwareSerial.c-7.c │ │ │ ├── HardwareSerial.c-8.c │ │ │ ├── HardwareSerial.c-9.c │ │ │ ├── HardwareSerial.c.h │ │ │ ├── HardwareSerial.h │ │ │ ├── Print-float.c │ │ │ ├── Print.c │ │ │ ├── Print.h │ │ │ ├── SPI.c │ │ │ ├── SPI.h │ │ │ ├── Serial.h │ │ │ ├── WInterrupts.c │ │ │ ├── WMath.c │ │ │ ├── binary.h │ │ │ ├── main.c │ │ │ ├── stm8s_it.h │ │ │ ├── weak_atexit.c │ │ │ ├── weak_initVariant.c │ │ │ ├── weak_serialEvent.c │ │ │ ├── wiring-alternate-function.c │ │ │ ├── wiring-delay-microseconds.c │ │ │ ├── wiring-delay.c │ │ │ ├── wiring-header.h │ │ │ ├── wiring-init.c │ │ │ ├── wiring-micros.c │ │ │ ├── wiring-millis.c │ │ │ ├── wiring_analog.c │ │ │ ├── wiring_digital-tables.c │ │ │ ├── wiring_digital.c-1.c │ │ │ ├── wiring_digital.c-2.c │ │ │ ├── wiring_digital.c-3.c │ │ │ ├── wiring_digital.c-4.c │ │ │ ├── wiring_digital.c-5.c │ │ │ ├── wiring_digital.c-6.c │ │ │ ├── wiring_digital.c-7.c │ │ │ ├── wiring_digital.c.h │ │ │ ├── wiring_private.h │ │ │ ├── wiring_pulse.c │ │ │ ├── wiring_shift.c │ │ │ └── xmacro.h │ ├── libraries │ │ ├── EEPROM │ │ │ ├── README.md │ │ │ ├── examples │ │ │ │ ├── eeprom_clear │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_clear.ino │ │ │ │ ├── eeprom_crc │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_crc.ino │ │ │ │ ├── eeprom_get │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_get.ino │ │ │ │ ├── eeprom_iteration │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_iteration.ino │ │ │ │ ├── eeprom_put │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_put.ino │ │ │ │ ├── eeprom_read │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_read.ino │ │ │ │ ├── eeprom_update │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_update.ino │ │ │ │ └── eeprom_write │ │ │ │ │ ├── Makefile │ │ │ │ │ └── eeprom_write.ino │ │ │ ├── keywords.txt │ │ │ ├── library.properties │ │ │ └── src │ │ │ │ ├── EEPROM.h │ │ │ │ ├── EEPROM_update.c │ │ │ │ ├── EEPROM_write.c │ │ │ │ └── utility │ │ │ │ ├── eeprom_lock.c │ │ │ │ ├── eeprom_read_block.c │ │ │ │ ├── eeprom_unlock.c │ │ │ │ ├── eeprom_update_block.c │ │ │ │ └── eeprom_write_block.c │ │ ├── Generic_Examples │ │ │ ├── empty.h │ │ │ └── examples │ │ │ │ ├── 01.Basics │ │ │ │ ├── AnalogReadSerial │ │ │ │ │ ├── AnalogReadSerial.ino │ │ │ │ │ ├── AnalogReadSerial.txt │ │ │ │ │ └── Makefile │ │ │ │ ├── BareMinimum │ │ │ │ │ ├── BareMinimum.ino │ │ │ │ │ ├── BareMinimum.txt │ │ │ │ │ └── Makefile │ │ │ │ ├── Blink │ │ │ │ │ ├── Blink.ino │ │ │ │ │ ├── Blink.txt │ │ │ │ │ └── Makefile │ │ │ │ ├── DigitalReadSerial │ │ │ │ │ ├── DigitalReadSerial.ino │ │ │ │ │ ├── DigitalReadSerial.txt │ │ │ │ │ └── Makefile │ │ │ │ ├── Fade │ │ │ │ │ ├── Fade.ino │ │ │ │ │ ├── Fade.txt │ │ │ │ │ └── Makefile │ │ │ │ └── ReadAnalogVoltage │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── ReadAnalogVoltage.ino │ │ │ │ │ └── ReadAnalogVoltage.txt │ │ │ │ ├── 02.Digital │ │ │ │ ├── BlinkWithoutDelay │ │ │ │ │ ├── BlinkWithoutDelay.ino │ │ │ │ │ ├── BlinkWithoutDelay.txt │ │ │ │ │ └── Makefile │ │ │ │ ├── Button │ │ │ │ │ ├── Button.ino │ │ │ │ │ ├── Button.txt │ │ │ │ │ └── Makefile │ │ │ │ ├── Debounce │ │ │ │ │ ├── Debounce.ino │ │ │ │ │ ├── Debounce.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── button.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── DigitalInputPullup │ │ │ │ │ ├── DigitalInputPullup.ino │ │ │ │ │ ├── DigitalInputPullup.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ └── StateChangeDetection │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── StateChangeDetection.ino │ │ │ │ │ ├── StateChangeDetection.txt │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── 03.Analog │ │ │ │ ├── AnalogInOutSerial │ │ │ │ │ ├── AnalogInOutSerial.ino │ │ │ │ │ ├── AnalogInOutSerial.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── AnalogInput │ │ │ │ │ ├── AnalogInput.ino │ │ │ │ │ ├── AnalogInput.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── Calibration │ │ │ │ │ ├── Calibration.ino │ │ │ │ │ ├── Calibration.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── Fading │ │ │ │ │ ├── Fading.ino │ │ │ │ │ ├── Fading.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ └── Smoothing │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── Smoothing.ino │ │ │ │ │ ├── Smoothing.txt │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── 04.Communication │ │ │ │ ├── ASCIITable │ │ │ │ │ ├── ASCIITable.ino │ │ │ │ │ ├── ASCIITable.txt │ │ │ │ │ └── Makefile │ │ │ │ ├── Dimmer │ │ │ │ │ ├── Dimmer.ino │ │ │ │ │ ├── Dimmer.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── Graph │ │ │ │ │ ├── Graph.ino │ │ │ │ │ ├── Graph.txt │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── SerialCallResponse │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── SerialCallResponse.ino │ │ │ │ │ ├── SerialCallResponse.txt │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ └── SerialCallResponseASCII │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── SerialCallResponseASCII.ino │ │ │ │ │ ├── SerialCallResponseASCII.txt │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ ├── 06.Sensors │ │ │ │ └── Ping │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── Ping.ino │ │ │ │ │ ├── Ping.txt │ │ │ │ │ ├── layout.png │ │ │ │ │ └── schematic.png │ │ │ │ └── 07.Display │ │ │ │ └── barGraph │ │ │ │ ├── LEDBarGraph.txt │ │ │ │ ├── Makefile │ │ │ │ ├── barGraph.ino │ │ │ │ ├── layout.png │ │ │ │ └── schematic.png │ │ ├── I2C │ │ │ ├── I2C.c │ │ │ ├── I2C.h │ │ │ ├── examples │ │ │ │ ├── BTHQ21605V_LCD │ │ │ │ │ └── BTHQ21605V_LCD.ino │ │ │ │ ├── HMC5883L │ │ │ │ │ └── HMC5883L.pde │ │ │ │ ├── busscan │ │ │ │ │ ├── Makefile │ │ │ │ │ └── busscan.ino │ │ │ │ └── pcf8574 │ │ │ │ │ ├── Makefile │ │ │ │ │ └── pcf8574.ino │ │ │ └── keywords.txt │ │ ├── LCD_BTHQ21605V │ │ │ ├── LCD_BTHQ21605V.c │ │ │ ├── LCD_BTHQ21605V.h │ │ │ ├── examples │ │ │ │ └── HelloWorld │ │ │ │ │ └── HelloWorld.ino │ │ │ ├── extras │ │ │ │ └── LCD_datasheet.pdf │ │ │ └── keywords.txt │ │ ├── LiquidCrystal │ │ │ ├── README.adoc │ │ │ ├── examples │ │ │ │ ├── Autoscroll │ │ │ │ │ ├── Autoscroll.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── Blink │ │ │ │ │ ├── Blink.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── Cursor │ │ │ │ │ ├── Cursor.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── CustomCharacter │ │ │ │ │ ├── CustomCharacter.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── Display │ │ │ │ │ ├── Display.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── HelloWorld │ │ │ │ │ ├── HelloWorld.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── Scroll │ │ │ │ │ ├── Makefile │ │ │ │ │ └── Scroll.ino │ │ │ │ ├── SerialDisplay │ │ │ │ │ ├── Makefile │ │ │ │ │ └── SerialDisplay.ino │ │ │ │ ├── TextDirection │ │ │ │ │ ├── Makefile │ │ │ │ │ └── TextDirection.ino │ │ │ │ └── setCursor │ │ │ │ │ ├── Makefile │ │ │ │ │ └── setCursor.ino │ │ │ ├── keywords.txt │ │ │ ├── library.properties │ │ │ └── src │ │ │ │ ├── LiquidCrystal.c │ │ │ │ └── LiquidCrystal.h │ │ ├── LiquidCrystal_I2C │ │ │ ├── README.md │ │ │ ├── examples │ │ │ │ ├── BlinkingCursor │ │ │ │ │ ├── BlinkingCursor.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── CustomChars │ │ │ │ │ ├── CustomChars.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── HelloWorld │ │ │ │ │ ├── HelloWorld.ino │ │ │ │ │ └── Makefile │ │ │ │ └── SerialDisplay │ │ │ │ │ ├── Makefile │ │ │ │ │ └── SerialDisplay.ino │ │ │ ├── keywords.txt │ │ │ ├── library.properties │ │ │ └── src │ │ │ │ ├── LiquidCrystal_I2C.c │ │ │ │ └── LiquidCrystal_I2C.h │ │ ├── LiquidCrystal_pcf2119 │ │ │ ├── examples │ │ │ │ ├── BlinkingCursor │ │ │ │ │ ├── BlinkingCursor.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── CustomChars │ │ │ │ │ ├── CustomChars.ino │ │ │ │ │ └── Makefile │ │ │ │ ├── HelloWorld │ │ │ │ │ ├── HelloWorld.ino │ │ │ │ │ └── Makefile │ │ │ │ └── SerialDisplay │ │ │ │ │ ├── Makefile │ │ │ │ │ └── SerialDisplay.ino │ │ │ ├── keywords.txt │ │ │ ├── library.properties │ │ │ ├── src │ │ │ │ ├── LiquidCrystal_pcf2119.c │ │ │ │ └── LiquidCrystal_pcf2119.h │ │ │ └── test_library.txt │ │ ├── Mini_SSD1306 │ │ │ ├── Mini_SSD1306.c │ │ │ ├── Mini_SSD1306.h │ │ │ └── examples │ │ │ │ └── oled-mini │ │ │ │ ├── Makefile │ │ │ │ ├── Makefile.classic │ │ │ │ └── oled-mini.ino │ │ ├── PCD8544 │ │ │ ├── LICENSE.txt │ │ │ ├── PCD8544.c │ │ │ ├── PCD8544.h │ │ │ ├── README.md │ │ │ ├── charset.inc │ │ │ ├── examples │ │ │ │ ├── HelloWorld │ │ │ │ │ ├── HelloWorld.ino │ │ │ │ │ └── Makefile │ │ │ │ └── Thermometer │ │ │ │ │ ├── Makefile │ │ │ │ │ └── Thermometer.ino │ │ │ └── library.properties │ │ ├── Servo │ │ │ ├── README.adoc │ │ │ ├── examples │ │ │ │ ├── Knob │ │ │ │ │ ├── Knob.ino │ │ │ │ │ └── Makefile │ │ │ │ └── Sweep │ │ │ │ │ ├── Makefile │ │ │ │ │ └── Sweep.ino │ │ │ ├── keywords.txt │ │ │ ├── library.properties │ │ │ └── src │ │ │ │ ├── Servo.h │ │ │ │ └── stm8 │ │ │ │ ├── Servo.c │ │ │ │ └── ServoTimers.h │ │ ├── Stepper │ │ │ ├── README.adoc │ │ │ ├── examples │ │ │ │ ├── MotorKnob │ │ │ │ │ ├── Makefile │ │ │ │ │ └── MotorKnob.ino │ │ │ │ ├── stepper_oneRevolution │ │ │ │ │ ├── Makefile │ │ │ │ │ └── stepper_oneRevolution.ino │ │ │ │ ├── stepper_oneStepAtATime │ │ │ │ │ ├── Makefile │ │ │ │ │ └── stepper_oneStepAtATime.ino │ │ │ │ └── stepper_speedControl │ │ │ │ │ ├── Makefile │ │ │ │ │ └── stepper_speedControl.ino │ │ │ ├── keywords.txt │ │ │ ├── library.properties │ │ │ └── src │ │ │ │ ├── Stepper.c │ │ │ │ └── Stepper.h │ │ └── Wire │ │ │ ├── examples │ │ │ ├── SFRRanger_reader │ │ │ │ ├── Makefile │ │ │ │ └── SFRRanger_reader.ino │ │ │ ├── digital_potentiometer │ │ │ │ ├── Makefile │ │ │ │ └── digital_potentiometer.ino │ │ │ ├── i2c_scanner │ │ │ │ ├── Makefile │ │ │ │ └── i2c_scanner.ino │ │ │ ├── master_reader │ │ │ │ ├── Makefile │ │ │ │ └── master_reader.ino │ │ │ ├── master_writer │ │ │ │ ├── Makefile │ │ │ │ └── master_writer.ino │ │ │ ├── pcf8574 │ │ │ │ ├── Makefile │ │ │ │ └── pcf8574.ino │ │ │ ├── slave_receiver │ │ │ │ └── slave_receiver.ino │ │ │ └── slave_sender │ │ │ │ └── slave_sender.ino │ │ │ ├── keywords.txt │ │ │ ├── library.properties │ │ │ └── src │ │ │ ├── Wire.c │ │ │ ├── Wire.h │ │ │ └── utility │ │ │ ├── twi.c │ │ │ └── twi.h │ ├── platform.txt │ ├── programmers.txt │ ├── sduino.mk │ └── variants │ │ ├── mb208 │ │ └── pins_arduino.h │ │ ├── s8uno │ │ └── pins_arduino.h │ │ ├── standard │ │ └── pins_arduino.h │ │ ├── stm8sblack │ │ └── pins_arduino.h │ │ └── stm8sdisco │ │ └── pins_arduino.h └── tools │ ├── armhf │ └── stm8gal │ ├── linux32 │ ├── stm8flash │ └── stm8gal │ ├── linux64 │ ├── stm8flash │ └── stm8gal │ ├── macosx │ ├── stm8flash │ └── stm8gal │ ├── win │ ├── busybox.exe │ ├── libusb-1.0.dll │ ├── stm8flash.exe │ └── stm8gal.exe │ └── wrapper │ ├── sdar.sh │ ├── sdcc-link.sh │ ├── sdcc.sh │ └── sdsize.sh ├── test ├── adc1 │ ├── Makefile │ ├── Makefile.classic │ └── adc1.c ├── attachInterrupt │ ├── Makefile │ └── attachInterrupt.ino ├── digitalWrite │ ├── Makefile │ ├── Makefile.classic │ ├── digitalWrite.c │ ├── stm8s_conf.h │ └── stm8s_it.h ├── iolib │ ├── Makefile │ ├── iolib.c │ ├── printhex.h │ └── printhex.s ├── libmake │ ├── Makefile │ ├── Makefile.classic │ ├── NON-FUNCTIONAL │ ├── README.md │ ├── libmake.c │ └── stat.awk ├── logs │ ├── test-v0.4.0-11-g87f15d6.log │ ├── test-v0.4.0-12-gc7ebb07.log │ ├── test-v0.4.0-24-g6d0fbd3.log │ ├── test-v0.4.0-25-gc38409c.log │ ├── test-v0.4.0-51-gcd681a2.log │ ├── test-v0.4.0-53-ga9863f5.log │ └── test-v0.4.0-61-g412a804.log ├── make-test.sh ├── pinmode │ ├── Makefile │ ├── README.md │ ├── main.c │ ├── pinmode-asm.c │ ├── pinmode-c.c │ ├── pinmode-fast.c │ ├── sim │ └── test_generic.c ├── print │ ├── Makefile │ ├── Makefile.classic │ └── print.c ├── pwm1 │ ├── Makefile │ ├── Makefile.classic │ └── pwm1.c ├── serial │ ├── Makefile │ ├── NON-FUNCTIONAL │ ├── serial.c │ ├── stm8s_conf.h │ └── stm8s_it.h ├── serial2 │ ├── Makefile │ ├── Makefile.classic │ └── serial2.c ├── serialEvent │ ├── Makefile │ └── serialEvent.c ├── spi │ ├── Makefile │ ├── Makefile.classic │ └── spi.c ├── timer1 │ ├── Makefile │ ├── Makefile.classic │ └── timer1.c ├── timer2 │ ├── Makefile │ ├── Makefile.classic │ └── timer2.c ├── uart-nospl │ ├── Makefile │ └── uart-nospl.c └── valist │ ├── Makefile │ └── main.c └── tools ├── .gitignore ├── Makefile ├── format_examples.sh ├── lib └── windows │ ├── libusb-1.0.dll │ └── libusb-1.0 │ └── libusb.h └── sdcc-critcal.patch /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *bak 3 | .*.swp 4 | *.jsone 5 | # ignore all kinds of binary files: 6 | *.o 7 | *.bin 8 | *.ihx 9 | *.hex 10 | *.exe 11 | tags 12 | # ignore files generated by sdcc: 13 | *.cdb 14 | *.adb 15 | *.ihx 16 | *.asm 17 | *.lst 18 | *.rel 19 | *.rst 20 | *.sym 21 | *.lk 22 | *.map 23 | # ignore files generated by the Arduino make system: 24 | build-*/ 25 | # ignore test log files: 26 | *test.log 27 | # ignore files generated by patch: 28 | *.orig 29 | *.rej 30 | # ignore mkdocs build directory 31 | site/ 32 | # ignore my scratch directory 33 | notes/ 34 | .DS_Store 35 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/stm8gal"] 2 | path = tools/stm8gal 3 | url = https://github.com/tenbaht/stm8gal.git 4 | branch = detectMode 5 | [submodule "tools/stm8flash"] 6 | path = tools/stm8flash 7 | url = git@github.com:tenbaht/stm8flash.git 8 | -------------------------------------------------------------------------------- /board-manager/.gitignore: -------------------------------------------------------------------------------- 1 | package_testserver_index.json 2 | release 3 | -------------------------------------------------------------------------------- /board-manager/Makefile.sdcc: -------------------------------------------------------------------------------- 1 | NAME=sdcc 2 | ifndef COREVERSION 3 | $(error COREVERSION is not set) 4 | endif 5 | 6 | ifndef SDCCVERSION 7 | $(error SDCCVERSION is not set) 8 | endif 9 | 10 | # Makefile.sdcc 11 | # 12 | # Build the sdcc archive files. 13 | # 14 | # Targets: 15 | # 16 | # - (default): 17 | # build a new tools entry in the parts directory. 18 | # - repack SDCCVERSION=10738 COREVERSION=xx 19 | # repack the snapshot files in the Downloads directory into stipped 20 | # down SDunino minimal packages. 21 | # COREVERSION doesn't matter, but needs to be present. 22 | 23 | 24 | # where to look for the original SDCC snapshot files 25 | #SNAPSHOTDIR=sdcc-snapshots 26 | 27 | # where to put the generated files 28 | SDCCDIR=release/v$(COREVERSION) 29 | PARTSDIR=parts 30 | 31 | VERSION=$(SDCCVERSION) 32 | 33 | .PHONY: repack 34 | 35 | # 36 | ### No user serviceable part below here. Only generated content. ######## 37 | # 38 | 39 | # The filename stem of the tools archives to be generated 40 | # (up to the first dash '-') 41 | TOOLS_STEM=$(SDCCDIR)/$(NAME) 42 | 43 | # The individual filenames for the different sdcc archives 44 | SDCC_TARS=$(wildcard $(TOOLS_STEM)-*-$(VERSION).*) 45 | 46 | # filename for the new tools entries 47 | TOOLS_ENTRY=$(PARTSDIR)/tools-entry-$(NAME)-$(VERSION).txt 48 | 49 | 50 | $(TOOLS_ENTRY) : $(SDCC_TARS) 51 | ./gen_tools_entry.sh "$(TOOLS_STEM)" "$(VERSION)" "$(COREVERSION)" > $@ 52 | 53 | repack: 54 | for i in ~/Downloads/sdcc*$(SDCCVERSION)*; do \ 55 | ./minimize-sdcc.sh $$i; \ 56 | done 57 | -------------------------------------------------------------------------------- /board-manager/assemble.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This is a very basic template "engine" to generate a full platform index 4 | # file. 5 | 6 | 7 | if [ $# -ne 1 ]; then 8 | echo " 9 | usage: $0 packagefile 10 | 11 | Insert all objects from parts/ directory in the platform and tools field 12 | of the json template file to assemble the final package file. 13 | " 14 | exit 1 15 | fi 16 | 17 | PACKAGEFILE=$1 18 | 19 | cp -a package_template.json ${PACKAGEFILE} 20 | 21 | for i in parts/platform*.txt; do 22 | sed -ie "/\"platforms\" : \[/r $i" ${PACKAGEFILE}; 23 | done; 24 | 25 | for i in parts/tools*.txt; do 26 | sed -ie "/\"tools\" : \[/r $i" ${PACKAGEFILE}; 27 | done; 28 | 29 | # The template contains an empty {} as a 'end of list' marker. We need to 30 | # remove this marker and the comma right before it. This can be done by some 31 | # sed magic: 32 | # 33 | # compact: sed -e '/},/{N;s/},\s*{}/}/}' package_sduino_stm8_index.json 34 | # (slightly) more readable: 35 | sed -ie '/},/{ 36 | N; 37 | s/},\s*{}/}/ 38 | }' ${PACKAGEFILE} 39 | -------------------------------------------------------------------------------- /board-manager/package_template.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | { 4 | "name": "sduino", 5 | "maintainer": "Michael Mayer", 6 | "websiteURL": "https://tenbaht.github.io/sduino/", 7 | "email": "michael-mayer@gmx.de", 8 | "help": { 9 | "online": "http://www.stm32duino.com/viewforum.php?f=52" 10 | }, 11 | "platforms" : [ 12 | {} 13 | ], 14 | "tools" : [ 15 | {} 16 | ] 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /board-manager/parts/platform-entry-sduino-0.3.0.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sduino STM8 plain C core (non-C++)", 3 | "architecture": "stm8", 4 | "version": "0.3.0", 5 | "category": "Contributed", 6 | "boards": [ 7 | {"name": "STM8S103F3 Breakout Board"}, 8 | {"name": "STM8S105C6 Discovery Board"} 9 | ], 10 | "toolsDependencies": [ 11 | { 12 | "name": "STM8Tools", 13 | "version": "2017.10.21", 14 | "packager": "sduino" 15 | }, 16 | { 17 | "name": "sdcc", 18 | "version": "build.10088", 19 | "packager": "sduino" 20 | } 21 | ], 22 | "url": "https://github.com/tenbaht/sduino/releases/download/v0.3.0/sduino-core-0.3.0.tar.bz2", 23 | "archiveFileName": "sduino-core-0.3.0.tar.bz2", 24 | "checksum": "SHA-256:5e3b2b950954e1004ef78084063374c59b37f682ba43f1789bc40d66d88e9994", 25 | "size": "4261038" 26 | }, 27 | -------------------------------------------------------------------------------- /board-manager/parts/platform-entry-sduino-0.3.1.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sduino STM8 plain C core (non-C++)", 3 | "architecture": "stm8", 4 | "version": "0.3.1", 5 | "category": "Contributed", 6 | "boards": [ 7 | {"name": "STM8S103F3 Breakout Board"}, 8 | {"name": "STM8S105C6 Discovery Board"} 9 | ], 10 | "toolsDependencies": [ 11 | { 12 | "name": "STM8Tools", 13 | "version": "2017.11.06", 14 | "packager": "sduino" 15 | }, 16 | { 17 | "name": "sdcc", 18 | "version": "build.10088", 19 | "packager": "sduino" 20 | } 21 | ], 22 | "url": "https://github.com/tenbaht/sduino/releases/download/v0.3.1/sduino-core-0.3.1.tar.bz2", 23 | "archiveFileName": "sduino-core-0.3.1.tar.bz2", 24 | "checksum": "SHA-256:9d5c5d0c96c8e18efc16820f17d88ec59c48ba59a84ce46dc9ccd8fc45c59016", 25 | "size": "4347217" 26 | }, 27 | -------------------------------------------------------------------------------- /board-manager/parts/platform-entry-sduino-0.3.2.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sduino STM8 plain C core (non-C++)", 3 | "architecture": "stm8", 4 | "version": "0.3.2", 5 | "category": "Contributed", 6 | "boards": [ 7 | {"name": "STM8S103F3 Breakout Board"}, 8 | {"name": "STM8S105C6 Discovery Board"} 9 | ], 10 | "toolsDependencies": [ 11 | { 12 | "name": "STM8Tools", 13 | "version": "2017.11.06", 14 | "packager": "sduino" 15 | }, 16 | { 17 | "name": "sdcc", 18 | "version": "build.10088", 19 | "packager": "sduino" 20 | } 21 | ], 22 | "url": "https://github.com/tenbaht/sduino/releases/download/v0.3.2/sduino-core-0.3.2.tar.bz2", 23 | "archiveFileName": "sduino-core-0.3.2.tar.bz2", 24 | "checksum": "SHA-256:dc10f5b21030db9ccc1cc8b935a7f2cf48bc1226629b3e7c87e7047c79b5c9ae", 25 | "size": "5627842" 26 | }, 27 | -------------------------------------------------------------------------------- /board-manager/parts/platform-entry-sduino-0.3.3.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sduino STM8 plain C core (non-C++)", 3 | "architecture": "stm8", 4 | "version": "0.3.3", 5 | "category": "Contributed", 6 | "boards": [ 7 | {"name": "STM8S103F3 Breakout Board"}, 8 | {"name": "STM8S105C6 Discovery Board"} 9 | ], 10 | "toolsDependencies": [ 11 | { 12 | "name": "STM8Tools", 13 | "version": "2017.11.13", 14 | "packager": "sduino" 15 | }, 16 | { 17 | "name": "sdcc", 18 | "version": "build.10088", 19 | "packager": "sduino" 20 | } 21 | ], 22 | "url": "https://github.com/tenbaht/sduino/releases/download/v0.3.3/sduino-core-0.3.3.tar.bz2", 23 | "archiveFileName": "sduino-core-0.3.3.tar.bz2", 24 | "checksum": "SHA-256:58f2f08a3172cff3575ec0aa412b248a7c9b5f4c1c5a6aa91dc55d7133c4d5a6", 25 | "size": "5643135" 26 | }, 27 | -------------------------------------------------------------------------------- /board-manager/parts/platform-entry-sduino-0.4.0.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sduino STM8 plain C core (non-C++)", 3 | "architecture": "stm8", 4 | "version": "0.4.0", 5 | "category": "Contributed", 6 | "boards": [ 7 | {"name": "STM8S103F3 Breakout Board"}, 8 | {"name": "STM8S105C6 Discovery Board"}, 9 | {"name": "STM8S105K4T6 Breakout Board"}, 10 | {"name": "sduino UNO (STM8S105K6)"}, 11 | {"name": "sduino MB (STM8S208MBT6B)"} 12 | ], 13 | "toolsDependencies": [ 14 | { 15 | "name": "STM8Tools", 16 | "version": "2018.12.07", 17 | "packager": "sduino" 18 | }, 19 | { 20 | "name": "sdcc", 21 | "version": "build.10738", 22 | "packager": "sduino" 23 | } 24 | ], 25 | "url": "https://github.com/tenbaht/sduino/releases/download/v0.4.0/sduino-core-0.4.0.tar.bz2", 26 | "archiveFileName": "sduino-core-0.4.0.tar.bz2", 27 | "checksum": "SHA-256:a71dee029991653577c63c9cebe70095b2c08d5b55a9aa0af836f527daf44d8c", 28 | "size": "6110413" 29 | }, 30 | -------------------------------------------------------------------------------- /board-manager/parts/platform-entry-sduino-0.5-pre2.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sduino STM8 plain C core (non-C++)", 3 | "architecture": "stm8", 4 | "version": "0.5-pre2", 5 | "category": "Contributed", 6 | "boards": [ 7 | {"name": "STM8S103F3 Breakout Board"}, 8 | {"name": "STM8S105C6 Discovery Board"}, 9 | {"name": "STM8S105K4T6 Breakout Board"}, 10 | {"name": "sduino UNO (STM8S105K6)"}, 11 | {"name": "sduino MB (STM8S208MBT6B)"} 12 | ], 13 | "toolsDependencies": [ 14 | { 15 | "name": "STM8Tools", 16 | "version": "2019.02.05", 17 | "packager": "sduino" 18 | }, 19 | { 20 | "name": "sdcc", 21 | "version": "build.10738", 22 | "packager": "sduino" 23 | } 24 | ], 25 | "url": "https://github.com/tenbaht/sduino/releases/download/v0.5-pre2/sduino-core-0.5-pre2.tar.bz2", 26 | "archiveFileName": "sduino-core-0.5-pre2.tar.bz2", 27 | "checksum": "SHA-256:13f039942368fdc2fea5470c2d3d58d9fb377cc7ca9502b1177f11ae8c75a7d8", 28 | "size": "2263319" 29 | }, 30 | -------------------------------------------------------------------------------- /board-manager/parts/platform-entry-sduino-0.5.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sduino STM8 plain C core (non-C++)", 3 | "architecture": "stm8", 4 | "version": "0.5", 5 | "category": "Contributed", 6 | "boards": [ 7 | {"name": "STM8S103F3 Breakout Board"}, 8 | {"name": "STM8S105C6 Discovery Board"}, 9 | {"name": "STM8S105K4T6 Breakout Board"}, 10 | {"name": "sduino UNO (STM8S105K6)"}, 11 | {"name": "sduino MB (STM8S208MBT6B)"} 12 | ], 13 | "toolsDependencies": [ 14 | { 15 | "name": "STM8Tools", 16 | "version": "2019.02.05", 17 | "packager": "sduino" 18 | }, 19 | { 20 | "name": "sdcc", 21 | "version": "build.11242", 22 | "packager": "sduino" 23 | } 24 | ], 25 | "url": "https://github.com/tenbaht/sduino/releases/download/v0.5/sduino-core-0.5.tar.bz2", 26 | "archiveFileName": "sduino-core-0.5.tar.bz2", 27 | "checksum": "SHA-256:16a8083583c704b18921cf5f8ededde925d313b4af6d9d64fa95ae2255e2bbf5", 28 | "size": "2263740" 29 | }, 30 | -------------------------------------------------------------------------------- /docs/api/HardwareSerial.md: -------------------------------------------------------------------------------- 1 | # HardwareSerial 2 | 3 | Uses the UART. API similar to Arduino. Single instance only. 4 | Pre-instanciated. 5 | 6 | This page is only a stub. 7 | 8 | 9 | ## API 10 | ## Example 11 | ## Implementation details 12 | ## Possible impovements 13 | -------------------------------------------------------------------------------- /docs/api/Print.md: -------------------------------------------------------------------------------- 1 | # Print 2 | 3 | Formatting functions for use with other output libraries. Involves serious 4 | preprocessor magic. See the [migration guidelines](../api/migration.md) and 5 | the [xmacro description](../developer/macro.md) 6 | 7 | This page is only a stub. 8 | 9 | 10 | ## API 11 | ## Example 12 | ## Implementation details 13 | ## Possible impovements 14 | -------------------------------------------------------------------------------- /docs/api/SPI.md: -------------------------------------------------------------------------------- 1 | # SPI 2 | 3 | Real hardware-SPI up to 10MHz. No interrupt support yet. 4 | 5 | This page is only a stub. 6 | 7 | 8 | ## API 9 | ## Example 10 | ## Implementation details 11 | ## Possible impovements 12 | -------------------------------------------------------------------------------- /docs/api/oled-ssd1306.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/api/oled-ssd1306.jpg -------------------------------------------------------------------------------- /docs/contact.md: -------------------------------------------------------------------------------- 1 | # Contact 2 | 3 | 4 | ### Bug reports and other issues tightly related to the repository 5 | 6 | [github issue tracker](https://github.com/tenbaht/sduino/issues). 7 | 8 | 9 | ### More general topics and suggestions 10 | 11 | During the transfer of the STM32duinoforum from Roger Clark to STM the old 12 | STM8 board got lost somehow, but the old postings are archived and still 13 | [readable](https://stm32duinoforum.com/forum/viewforum_f_52.html). There is a 14 | [new STM8 board](https://www.stm32duino.com/viewforum.php?f=76) in the 15 | stm32duino forum. I was re-started on Oktober 2020, so there aren't many 16 | messages there yet. is not much going on there, but it is still the place to 17 | go to. 18 | 19 | 20 | 21 | ### email 22 | 23 | Please find my address in the commit messages of the repository (as a simple 24 | captcha test) or use the alias address sduino@gmx.de 25 | -------------------------------------------------------------------------------- /docs/developer/bare-metal-programming.md: -------------------------------------------------------------------------------- 1 | # Bare metal programming 2 | 3 | It all started by compiling some plain example programs without using any 4 | libraries. This avoids the code overhead of the Arduino libraries. 5 | 6 | Lujji posted a [series of 7 | articles](https://lujji.github.io/blog/bare-metal-programming-stm8/) on bare 8 | metal programming of the STM8S CPUs. This is by far the best introduction I 9 | found so far. It would have helped me a lot if it would have been around at 10 | the time when I started this project. 11 | 12 | 13 | 14 | 15 | ## Modifications for the sdcc example programs 16 | 17 | I started my journey into the STM8 world with the 18 | [stm8-examples-sdcc](https://github.com/vdudouyt/sdcc-examples-stm8) by 19 | Valentin Dudouyt (vdudouyt), the author of 20 | [stm8flash](https://github.com/vdudouyt/stm8flash). 21 | 22 | These examples are still part of the repository in 23 | examples/sdcc-examples-stm8. To compile for my STM8S103F3 board they 24 | required some modifications: 25 | 26 | **blinky.c**: LED pin assignment 27 | 28 | **uart.c**: pin assignment (TX is at PD5, RX is at PD6). 29 | The UART is sending at 1200 Baud => CPU clock only 2MHz instead of 16MHz. 30 | The clock divider needs to be configured or a different baud rate prescale value 31 | has to be used. Pitfall: The register address for the clock divider is 32 | different for the STM8S and the STM8L. 33 | 34 | -------------------------------------------------------------------------------- /docs/developer/coding-style.md: -------------------------------------------------------------------------------- 1 | # Coding style 2 | 3 | ## Development workflow 4 | 5 | I recently read this great article about [a successful branching 6 | model](https://nvie.com/posts/a-successful-git-branching-model/) for git and 7 | will implement it. Highly recommended! 8 | 9 | 10 | ## Changelog 11 | 12 | Every feature branch (or pull request) should include an update for 13 | Changelog.md 14 | 15 | 16 | ## Code format 17 | 18 | When porting an existing Arduino library I try to preserve the original 19 | formatting as much as possible to allow for easy comparison to the original 20 | state. 21 | 22 | There is a development of a C++ capable compiler environment going on. There 23 | is no public website for that project yet, but I am in contact with the 24 | developer. He is even targeting Sduino for his project and at one point in 25 | the (still distant) future we might be able to switch back to the orginal 26 | library code again. Preserved code structure would be a big plus then. (But 27 | don't hold your breath yet) 28 | 29 | Newly written code is mostly formatted using indent according to the linux 30 | kernel coding style, using Tabs, Tab width 8, line length 80: 31 | 32 | ```bash 33 | indent -linux 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/hardware/ST-LinkV2_pinout_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/ST-LinkV2_pinout_01.jpg -------------------------------------------------------------------------------- /docs/hardware/bad-etching.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/bad-etching.jpg -------------------------------------------------------------------------------- /docs/hardware/esp14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/esp14.png -------------------------------------------------------------------------------- /docs/hardware/st-link-v2-dongle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/st-link-v2-dongle.png -------------------------------------------------------------------------------- /docs/hardware/st-link_v2_baite.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/st-link_v2_baite.pdf -------------------------------------------------------------------------------- /docs/hardware/stm8blue-pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/stm8blue-pinout.png -------------------------------------------------------------------------------- /docs/hardware/stm8blue-schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/stm8blue-schematic.png -------------------------------------------------------------------------------- /docs/hardware/stm8blue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/stm8blue.jpg -------------------------------------------------------------------------------- /docs/hardware/stm8s003.md: -------------------------------------------------------------------------------- 1 | # STM8S003 2 | 3 | The STM8S003 is almost identical to the STM8S103. The only difference I am 4 | aware of is the size of the EEPROM: 128 bytes vs. 640 bytes. 5 | 6 | I am not sure why the '003 is sold for half the price, or, to put it the 7 | other way around, why anybody should choose the '103 at all. Did I miss an 8 | important difference? 9 | 10 | All you have to do in order to develop for the STM8S003 is setting the board 11 | manager for '[Generic STM8S103 breakout board](stm8blue.md)'. Just keep in 12 | mind not to use EEPROM locations above 127/0x7f. 13 | 14 | All differences between the CPUs: 15 | 16 | Feature | STM8S003 | STM8S103 17 | ------------ | ------------- | ------------ 18 | EEPROM size | 128 Bytes | 640 Bytes 19 | 20 | 21 | 22 | ## Known development boards 23 | 24 | I am not aware of any dedicated STM8S003 breakout board, but this CPU is 25 | used in many other low-cost boards: 26 | 27 | - [ESP-14](esp14.md) Wifi-Module 28 | - [W1209](w1209-thermostat.md) Temperature controller 29 | - HC-12 Wireless serial remote module 30 | 31 | The [stm8ef 32 | wiki](https://github.com/TG9541/stm8ef/wiki/STM8S-Value-Line-Gadgets) lists 33 | more. 34 | 35 | -------------------------------------------------------------------------------- /docs/hardware/stm8sblack-pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/stm8sblack-pinout.png -------------------------------------------------------------------------------- /docs/hardware/stm8sblack-schematic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/stm8sblack-schematic.jpg -------------------------------------------------------------------------------- /docs/hardware/stm8sblack.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/docs/hardware/stm8sblack.jpg -------------------------------------------------------------------------------- /docs/hardware/w1209-thermostat.md: -------------------------------------------------------------------------------- 1 | # W1209 Thermostat module 2 | 3 | Insanly cheap module with a relay, 3 digit display and a sensor connector. 4 | All of that for $1.60 including shipping! 5 | 6 | STM8S000F3P6 microcontroller, 8 KB Flash, 1 KB RAM, 128 bytes EEPROM 7 | 8 | - 12V supply voltage 9 | - One relay with indikator LED, max. 5A DC or 15A AC 10 | - three buttons 11 | - three digit 7-segment-display, multiplexed 12 | - external NTC temperture sensor, 10k 13 | 14 | But please be aware that the PCB layout violates all common safety rules on 15 | the high voltage side. No sufficient creeping distance, the PCB traces are 16 | way too small to actually carry 15A and the screw terminals are not up to 17 | that task either. 18 | 19 | 20 | ![connecting the board](https://github.com/mister-grumbler/w1209-firmware/raw/master/docs/st-link_conn_w1209.jpg) 21 | 22 | 23 | ## SWIM connector 24 | 25 | Pinout of SWIM connector 26 | 27 | Pin | Signal 28 | ---: | ------ 29 | 1 | Vcc (5V) 30 | 2 | SWIM 31 | 3 | NRST 32 | 4 | GND 33 | 34 | 35 | ## Schematic 36 | 37 | ![Schematic of W1209](https://github.com/mister-grumbler/w1209-firmware/raw/master/docs/thermostat-w1209.jpg) 38 | 39 | 40 | ## Further reading 41 | 42 | [Functionally identical firmware, GPL2'ed](https://github.com/mister-grumbler/w1209-firmware) 43 | -------------------------------------------------------------------------------- /docs/img/no-espstlink-10810e88.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makefile b/Makefile 2 | index 7ed48d1..eef1710 100644 3 | --- a/Makefile 4 | +++ b/Makefile 5 | @@ -39,6 +39,7 @@ else 6 | LIBS = -lusb-1.0 7 | LIBUSB_CFLAGS = 8 | CC ?= GCC 9 | + SKIP_ESP = yes 10 | BIN_SUFFIX =.exe 11 | endif 12 | 13 | @@ -47,7 +48,12 @@ override CFLAGS := $(BASE_CFLAGS) $(LIBUSB_CFLAGS) $(CFLAGS) 14 | 15 | 16 | BIN =stm8flash 17 | -OBJECTS =stlink.o stlinkv2.o espstlink.o main.o byte_utils.o ihex.o srec.o stm8.o libespstlink.o 18 | +OBJECTS =stlink.o stlinkv2.o main.o byte_utils.o ihex.o srec.o stm8.o 19 | +ifeq ($(SKIP_ESP),yes) 20 | + override CFLAGS += -DNO_ESP 21 | +else 22 | + OBJECTS +=espstlink.o libespstlink.o 23 | +endif 24 | 25 | 26 | .PHONY: all clean install 27 | diff --git a/main.c b/main.c 28 | index 21c5133..7ab575b 100644 29 | --- a/main.c 30 | +++ b/main.c 31 | @@ -81,6 +81,7 @@ programmer_t pgms[] = { 32 | stlink2_swim_read_range, 33 | stlink2_swim_write_range, 34 | }, 35 | +#ifndef NO_ESP 36 | { 37 | "espstlink", 38 | ESP_STLink, 39 | @@ -92,6 +93,7 @@ programmer_t pgms[] = { 40 | espstlink_swim_read_range, 41 | espstlink_swim_write_range, 42 | }, 43 | +#endif 44 | { NULL }, 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /docs/usage/board-manager-install.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | 4 | ## Using the Arduino Board Manager 5 | 6 | This is the recommanded way of installation now. 7 | 8 | - Open the Settings tab of the Preferences dialog 9 | - Enter 10 | `https://github.com/tenbaht/sduino/raw/master/package_sduino_stm8_index.json` 11 | as an Additional Boards Manager URL 12 | - Select *sduino* in the Boards Manager list (Tools->Board:...->Boards Manager) 13 | - Click on Install 14 | 15 | Wait for the download to finsh and you are ready to blink: 16 | 17 | - Open the Boards list at Tools->Board:... 18 | - You should find a new entry "STM8S Boards". 19 | - Choose *STM8S103F3 Breakout Board* from the list 20 | - Open the standard Blink example from File->Examples->01. Basics->Blink 21 | - Compile it by hitting 'Verify' 22 | 23 | Easy, isn't it? 24 | 25 | In order to upload the compiled sketch to a connected board you need to 26 | [install your flash tool](../hardware/flashtool/#installation-for-windows) 27 | first. 28 | 29 | 30 | 31 | ## Manual install 32 | 33 | Only if you prefer a Makefile based build over using the Arduino IDE or if 34 | you would like to help with the development of Sduino you will have to do a 35 | [manual installation](manual-install.md) instead. 36 | -------------------------------------------------------------------------------- /docs/usage/build-ide.md: -------------------------------------------------------------------------------- 1 | # Building with the Arduino IDE 2 | 3 | Sduino now blends in smoothly with the Arduino IDE. Just choose a matching 4 | board type from the list of supported boards at Tools->Board and work as 5 | usual. 6 | 7 | 8 | - Open the Boards list at Tools->Board:... 9 | - You should find a new entry "STM8S Boards". 10 | - Choose *STM8S103F3 Breakout Board* from the list 11 | - Open the standard Blink example from File->Examples->01. Basics->Blink 12 | - Compile it by clickin 'Verify' 13 | - Or upload it to the connected board by clicking 'Upload' 14 | 15 | Done! Your first STM8 based project is up and running! 16 | 17 | But keep in mind that it still based on plain C and not 100% Arduino syntax. 18 | It is close enough, that even some of the stock example sketches work right 19 | out of the box, but others will require small modifications. 20 | 21 | FIXME: How to access the Sduino adopted example sketches 22 | 23 | -------------------------------------------------------------------------------- /docs/usage/faq.md: -------------------------------------------------------------------------------- 1 | # FAQ/common problems 2 | 3 | ## Compilation issues 4 | 5 | ### ASlink-Warning-No definition of area SSEG 6 | 7 | This happens when there is no *.pde or *.ino file in the project directory, 8 | `Serial_begin()` is not used and only *.c files are compiled. 9 | 10 | This message means that main.c is not pulled in by the linker because there 11 | was no reference to main() anywhere. When processing *.pde/ino files 12 | `wrapper/sdcc.sh` (for IDE builds) or `Arduino.mk` (for Makefile builds) adds 13 | a reference to main: 14 | 15 | ``` 16 | /* add a dummy reference to main() to make sure to pull in main.c from the core library */ 17 | void main(void); 18 | void (*dummy_variable) () = main; 19 | ``` 20 | 21 | If there is no pde/ino file the user has to make sure main.c is pulled in by 22 | the linker or define its own main(). 23 | 24 | Possible ways to pull in main.c: 25 | 26 | - Use Serial_begin(): This references the variable runSerialEvent which in turn pulls in main.c (some overhead) 27 | - reference the variable runSerialEvent yourself: `begin(){runSerialEvent=0;}` (Overhead: 4 bytes flash) 28 | - add a reference to main() like above. (Overhead: 2 bytes RAM and 2 bytes flash) 29 | - define your own main() function. 30 | 31 | 32 | ### Flashing fails on the new board 33 | 34 | It might be locked/write protected. [Check 35 | this](../../hardware/stm8blue/#unlocking-a-write-protected-mcu) 36 | 37 | 38 | ## Hardware issues 39 | 40 | 41 | ### My new stm8blue board seems dead and does not respond to the flash tool 42 | 43 | ***Crap alert:*** There are [known quality 44 | issues](../../hardware/stm8blue/#crap-alert) with some more recent PCB 45 | production lots of the stm8blue boards. 46 | -------------------------------------------------------------------------------- /examples/blink-spl/Makefile: -------------------------------------------------------------------------------- 1 | SDCCBASE=/opt/sdcc 2 | BINDIR=$(SDCCBASE)/bin 3 | SDCC=$(BINDIR)/sdcc 4 | SDLD=$(BINDIR)/sdld 5 | 6 | OBJECT=blink 7 | OBJECTS=blink_spl.rel 8 | 9 | LIBDIR=../../STM8S_StdPeriph_Driver/src 10 | #LIBFILES=$(LIBDIR)/stm8s_gpio.rel 11 | LIBFILES=$(LIBDIR)/stm8s.lib 12 | 13 | CFLAGS=-DSTM8S103 -I. -I../../STM8S_StdPeriph_Driver/inc --debug 14 | 15 | 16 | .PHONY: all clean flash 17 | 18 | all: $(OBJECT).ihx 19 | 20 | clean: 21 | rm -f *.asm *.ihx *.rel *.sym *.map *.cdb *.lk *.lst *.rst *~ 22 | 23 | flash: $(OBJECT).ihx 24 | stm8flash -cstlinkv2 -pstm8s103?3 -w $(OBJECT).ihx 25 | 26 | $(OBJECT).ihx: $(OBJECTS) $(LIBFILES) 27 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(LDFLAGS) $^ -o $@ 28 | 29 | %.rel: %.c 30 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(CFLAGS) $(LDFLAGS) -c $< 31 | -------------------------------------------------------------------------------- /examples/blink-spl/README.md: -------------------------------------------------------------------------------- 1 | # blink_spl.c 2 | 3 | Blink a LED using SPL functions and the SDCC compiler. Example from 4 | http://www.mikrocontroller.net/articles/STM8S-Discovery 5 | modified for the stm8s103f3 board (LED at PD5). 6 | -------------------------------------------------------------------------------- /examples/blink-spl/blink_spl.c: -------------------------------------------------------------------------------- 1 | #include "stm8s.h" // (1) 2 | 3 | main() // (2) 4 | { 5 | GPIO_DeInit(GPIOB); // (3) 6 | GPIO_Init(GPIOB, GPIO_PIN_5,GPIO_MODE_OUT_PP_LOW_SLOW); // (4) 7 | 8 | while (1) // (5) 9 | { 10 | u16 i; // (6) 11 | 12 | for(i = 0; i < 60000; i++) // (7) 13 | { 14 | nop(); // (8) 15 | } 16 | 17 | GPIO_WriteReverse(GPIOB, GPIO_PIN_5); // (9) 18 | } // (10) 19 | } // (11) 20 | 21 | -------------------------------------------------------------------------------- /examples/fade-all-pins/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../sduino.mk 4 | -------------------------------------------------------------------------------- /examples/fade-all-pins/fade-all-pins.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fade-all-pins 3 | * 4 | * This example shows how to fade an LED on all PWM-capable pins 5 | * using the analogWrite() function. (Derived from 01.Basics/Fade) 6 | * 7 | * This example code is in the public domain. 8 | */ 9 | 10 | #include 11 | 12 | int brightness = 0; // how bright the LED is 13 | int fadeAmount = 5; // how many points to fade the LED by 14 | char i; 15 | 16 | // the setup routine runs once when you press reset: 17 | void setup() { 18 | // declare all pin to be an output: 19 | for (i=0; i 2 | #include "stm8s.h" 3 | 4 | int uart_write(const char *str) { 5 | char i; 6 | for(i = 0; i < strlen(str); i++) { 7 | while(!(USART1_SR & USART_SR_TXE)); 8 | USART1_DR = str[i]; 9 | } 10 | return(i); // Bytes sent 11 | } 12 | 13 | 14 | int main() { 15 | unsigned long i = 0; 16 | 17 | CLK_CKDIVR = 0x00; // Set the frequency to 16 MHz 18 | CLK_PCKENR1 = 0xFF; // Enable peripherals 19 | 20 | PD_DDR = 0x20; // Put TX line on 21 | PD_CR1 = 0x20; 22 | 23 | USART1_CR2 = USART_CR2_TEN; // Allow TX & RX 24 | USART1_CR3 &= ~(USART_CR3_STOP1 | USART_CR3_STOP2); // 1 stop bit 25 | USART1_BRR2 = 0x03; USART1_BRR1 = 0x68; // 9600 baud 26 | 27 | do { 28 | uart_write("Hello World!\r\n"); 29 | for(i = 0; i < 147456; i++) { } // Sleep 30 | } while(1); 31 | } 32 | -------------------------------------------------------------------------------- /examples/uart-int/Makefile: -------------------------------------------------------------------------------- 1 | SDCCBASE=/opt/sdcc 2 | BINDIR=$(SDCCBASE)/bin 3 | SDCC=$(BINDIR)/sdcc 4 | SDLD=$(BINDIR)/sdld 5 | 6 | OBJECT=uart 7 | OBJECTS=uart-int.rel 8 | 9 | LIBDIR=../../STM8S_StdPeriph_Driver/src 10 | #LIBFILES=$(LIBDIR)/stm8s_gpio.rel 11 | LIBFILES=$(LIBDIR)/stm8s.lib 12 | 13 | CFLAGS=-DSTM8S103 -I. -I../../STM8S_StdPeriph_Driver/inc --debug 14 | 15 | 16 | .PHONY: all clean flash 17 | 18 | all: $(OBJECT).ihx 19 | 20 | clean: 21 | rm -f *.asm *.ihx *.rel *.sym *.map *.cdb *.lk *.lst *.rst *~ 22 | 23 | flash: $(OBJECT).ihx 24 | stm8flash -cstlinkv2 -pstm8s103?3 -w $(OBJECT).ihx 25 | 26 | $(OBJECT).ihx: $(OBJECTS) $(LIBFILES) 27 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(LDFLAGS) $^ -o $@ 28 | 29 | %.rel: %.c 30 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(CFLAGS) $(LDFLAGS) -c $< 31 | -------------------------------------------------------------------------------- /examples/uart-int/README.md: -------------------------------------------------------------------------------- 1 | # uart-int 2 | 3 | simple uart example using interrupts and SPL functions. 4 | -------------------------------------------------------------------------------- /examples/uart-ringbuffer/Makefile: -------------------------------------------------------------------------------- 1 | SDCC=sdcc 2 | SDLD=sdld 3 | OBJECT=uart 4 | OBJECTS=uart-ringbuffer.rel 5 | 6 | LIBDIR=../../STM8S_StdPeriph_Driver/src 7 | #LIBFILES=$(LIBDIR)/stm8s_gpio.rel 8 | LIBFILES=$(LIBDIR)/stm8s.lib 9 | 10 | CFLAGS=-DSTM8S103 -I. -I../../STM8S_StdPeriph_Driver/inc 11 | 12 | 13 | .PHONY: all clean flash 14 | 15 | all: $(OBJECT).ihx 16 | 17 | clean: 18 | rm -f *.asm *.ihx *.rel *.sym *.map *.cdb *.lk *.lst *.rst *~ 19 | 20 | flash: $(OBJECT).ihx 21 | stm8flash -cstlinkv2 -pstm8s103?3 -w $(OBJECT).ihx 22 | 23 | $(OBJECT).ihx: $(OBJECTS) $(LIBFILES) 24 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(LDFLAGS) $^ -o $@ 25 | 26 | %.rel: %.c 27 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(CFLAGS) $(LDFLAGS) -c $< 28 | -------------------------------------------------------------------------------- /examples/uart-ringbuffer/README.md: -------------------------------------------------------------------------------- 1 | # uart-ringbuffer.c 2 | 3 | Adopted HardwareSerial.cpp from arduino-1.0 for use with the STM8S and SDCC 4 | using SPL functions. 5 | -------------------------------------------------------------------------------- /examples/uart-ringbuffer/uart-ringbuffer.h: -------------------------------------------------------------------------------- 1 | // Define config for Serial.begin(baud, config); 2 | /* coding of the bit field: 0www pp ss 3 | * wordlength www: 0:8 1:9 (5,6,7 not supported) 4 | * parity pp: 0:n 2:e 3:o 5 | * stopbits ss: 0:1 1:0.5 2:2 3:1.5 6 | * => 8:0x3x 9:0x4x 7 | * => n1:1 n2:2 e1:8 e2:A o1:C o2:E 8 | */ 9 | #define SERIAL_8N1 0x01 10 | #define SERIAL_9N1 0x11 11 | #define SERIAL_8N2 0x02 12 | #define SERIAL_9N2 0x12 13 | #define SERIAL_8E1 0x08 14 | #define SERIAL_9E1 0x18 15 | #define SERIAL_8E2 0x0A 16 | #define SERIAL_9E2 0x1A 17 | #define SERIAL_8O1 0x0C 18 | #define SERIAL_9O1 0x1C 19 | #define SERIAL_8O2 0x0E 20 | #define SERIAL_9O2 0x1E 21 | -------------------------------------------------------------------------------- /examples/uart-spl/Makefile: -------------------------------------------------------------------------------- 1 | SDCCBASE=/opt/sdcc 2 | BINDIR=$(SDCCBASE)/bin 3 | SDCC=$(BINDIR)/sdcc 4 | SDLD=$(BINDIR)/sdld 5 | 6 | OBJECT=uart 7 | OBJECTS=uart_spl.rel 8 | 9 | LIBDIR=../../STM8S_StdPeriph_Driver/src 10 | #LIBFILES=$(LIBDIR)/stm8s_gpio.rel 11 | LIBFILES=$(LIBDIR)/stm8s.lib 12 | 13 | CFLAGS=-DSTM8S103 -I. -I../../STM8S_StdPeriph_Driver/inc --debug 14 | 15 | 16 | .PHONY: all clean flash 17 | 18 | all: $(OBJECT).ihx 19 | 20 | clean: 21 | rm -f *.asm *.ihx *.rel *.sym *.map *.cdb *.lk *.lst *.rst *~ 22 | 23 | flash: $(OBJECT).ihx 24 | stm8flash -cstlinkv2 -pstm8s103?3 -w $(OBJECT).ihx 25 | 26 | $(OBJECT).ihx: $(OBJECTS) $(LIBFILES) 27 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(LDFLAGS) $^ -o $@ 28 | 29 | %.rel: %.c 30 | $(SDCC) -lstm8 -mstm8 --out-fmt-ihx $(CFLAGS) $(LDFLAGS) -c $< 31 | -------------------------------------------------------------------------------- /examples/uart-spl/README.md: -------------------------------------------------------------------------------- 1 | # uart-spl 2 | 3 | simple uart example using SPL functions. Sending only, polling only, no 4 | interrupts. 5 | 6 | -------------------------------------------------------------------------------- /examples/uart-spl/uart_spl.c: -------------------------------------------------------------------------------- 1 | #include"stm8s.h" 2 | 3 | void send_string(char *str) 4 | { 5 | char c; 6 | 7 | if (!str) return; 8 | 9 | while ( c=*str++ ) { // assignment intented 10 | while (!UART1_GetFlagStatus(UART1_FLAG_TXE)); 11 | UART1_SendData8(c); 12 | } 13 | } 14 | 15 | 16 | void main (void) 17 | { 18 | uint32_t i; 19 | 20 | UART1_DeInit(); 21 | UART1_Init(9600, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO, 22 | UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE); 23 | 24 | while (1) { 25 | send_string("Hello World!\n"); 26 | for (i=30000; i; i--); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sduino/lib/version.txt: -------------------------------------------------------------------------------- 1 | 2:1.8.7+sduino 2 | -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/Release_Notes.html -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF52Ax.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF52Ax.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF622x.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF622x.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF626x.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF626x.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF62Ax.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8AF62Ax.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S001.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S001.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S003.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S003.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S005.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S005.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S007.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S007.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S103.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S103.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S105.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S105.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S207.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S207.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S208.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S208.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S903.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/lib/STM8S903.lib -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/peripherie.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/peripherie.ods -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/peripherie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/peripherie.png -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_can.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_can.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_clk.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_clk.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim1.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim2.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim3.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim4.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim5.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim6.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_tim6.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_uart1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_uart1.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_uart2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_uart2.c -------------------------------------------------------------------------------- /sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_uart4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/STM8S_StdPeriph_Driver/src/stm8s_uart4.c -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-10.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | size_t HardwareSerial_write(uint8_t c) 5 | { 6 | int i = (tx_buffer.head + 1) % SERIAL_BUFFER_SIZE; 7 | 8 | // If the output buffer is full, there's nothing for it other than to 9 | // wait for the interrupt handler to empty it a bit 10 | // ???: return 0 here instead? 11 | while (i == tx_buffer.tail) 12 | ; 13 | 14 | tx_buffer.buffer[tx_buffer.head] = c; 15 | tx_buffer.head = i; 16 | 17 | #ifdef USE_SPL 18 | UARTx_ITConfig(UARTx_IT_TXE, ENABLE); // enable TXE interrupt 19 | #else 20 | UARTx->CR2 |= UARTx_CR2_TIEN; // enable TXE interrupt 21 | #endif 22 | transmitting = 1; 23 | //FIXME: unklar, ob das auf dem STM8 wirklich nötig ist. 24 | // Das TXE-Bit in UART_SR ist jedenfalls nur lesbar. 25 | // clear the TXC bit -- "can be cleared by writing a one to its bit location" 26 | // sbi(*_ucsra, TXC0); 27 | 28 | return 1; 29 | } 30 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-2.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | uint8_t HardwareSerial(void) 5 | { 6 | return initialized; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-3.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | void HardwareSerial_begin(unsigned long baud) 5 | { 6 | #ifdef USE_SPL 7 | //set the data bits, parity, and stop bits 8 | UARTx_Init(baud, 9 | UARTx_WORDLENGTH_8D, UARTx_STOPBITS_1, UARTx_PARITY_NO, 10 | UARTx_SYNCMODE_CLOCK_DISABLE, UARTx_MODE_TXRX_ENABLE); 11 | 12 | UARTx_ITConfig(UARTx_IT_RXNE, ENABLE); // enable RXNE interrupt 13 | #else 14 | uint16_t divider; 15 | 16 | /* Set the UARTx BaudRates in BRR1 and BRR2 registers according to UARTx_BaudRate value */ 17 | divider = (uint16_t) ((uint32_t)CLK_GetClockFreq() / (uint32_t) baud); 18 | 19 | UARTx->BRR2 = divider & 0x0f; 20 | divider >>= 4; 21 | UARTx->BRR1 = divider & 0xff; 22 | divider >> 4; 23 | UARTx->BRR2 |= (uint8_t) divider & 0xf0; 24 | 25 | UARTx->CR1 = 0; // 8 Bit, no parity 26 | UARTx->CR3 = 0; // one stop bit 27 | // enable RXNE interrupt, enable transmitter, enable receiver 28 | UARTx->CR2 = UARTx_CR2_RIEN | UARTx_CR2_TEN | UARTx_CR2_REN; 29 | #endif 30 | initialized = 1; 31 | runSerialEvent = 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-4.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | void HardwareSerial_begin_config(unsigned long baud, uint8_t config) 5 | { 6 | #ifdef USE_SPL 7 | UARTx_StopBits_TypeDef stopbits; 8 | UARTx_Parity_TypeDef parity; 9 | UARTx_WordLength_TypeDef wordlength; 10 | 11 | wordlength = (config & 0x10) ? UARTx_WORDLENGTH_9D : UARTx_WORDLENGTH_8D; 12 | stopbits = (config & 0x20) ? UARTx_STOPBITS_2 : UARTx_STOPBITS_1; 13 | parity=UARTx_PARITY_NO; // default 14 | config &= 0x6; 15 | if (config == 0x4) parity=UARTx_PARITY_EVEN; 16 | else if (config == 0x6) parity=UARTx_PARITY_ODD; 17 | 18 | //set the data bits, parity, and stop bits 19 | UARTx_Init(baud, wordlength, stopbits, parity, 20 | UARTx_SYNCMODE_CLOCK_DISABLE, UARTx_MODE_TXRX_ENABLE); 21 | 22 | UARTx_ITConfig(UARTx_IT_RXNE, ENABLE); // enable RXNE interrupt 23 | #else 24 | uint16_t divider; 25 | 26 | /* Set the UARTx BaudRates in BRR1 and BRR2 registers according to UARTx_BaudRate value */ 27 | divider = (uint16_t) ((uint32_t)CLK_GetClockFreq() / (uint32_t) baud); 28 | 29 | UARTx->BRR2 = divider & 0x0f; 30 | divider >>= 4; 31 | UARTx->BRR1 = divider & 0xff; 32 | divider >> 4; 33 | UARTx->BRR2 |= (uint8_t) divider & 0xf0; 34 | 35 | UARTx->CR1 = config & (MASK_DATABITS | MASK_PARITY); 36 | UARTx->CR3 = config & (MASK_STOPBITS); 37 | // enable RXNE interrupt, enable transmitter, enable receiver 38 | UARTx->CR2 = UARTx_CR2_RIEN | UARTx_CR2_TEN | UARTx_CR2_REN; 39 | #endif 40 | initialized = 1; 41 | runSerialEvent = 0; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-5.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | void HardwareSerial_end(void) 5 | { 6 | // wait for transmission of outgoing data 7 | while (tx_buffer.head != tx_buffer.tail) 8 | ; 9 | 10 | UARTx_DeInit(); 11 | 12 | // clear any received data 13 | rx_buffer.head = rx_buffer.tail; 14 | initialized = 0; 15 | runSerialEvent = 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-6.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | int HardwareSerial_available(void) 5 | { 6 | return (unsigned int)(SERIAL_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % SERIAL_BUFFER_SIZE; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-7.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | int HardwareSerial_peek(void) 5 | { 6 | if (rx_buffer.head == rx_buffer.tail) { 7 | // if (!runSerialEvent) { 8 | return -1; 9 | } else { 10 | return rx_buffer.buffer[rx_buffer.tail]; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-8.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | int HardwareSerial_read(void) 5 | { 6 | // if the head isn't ahead of the tail, we don't have any characters 7 | if (rx_buffer.head == rx_buffer.tail) { 8 | // if (!runSerialEvent) { 9 | return -1; 10 | } else { 11 | unsigned char c = rx_buffer.buffer[rx_buffer.tail]; 12 | rx_buffer.tail = (unsigned int)(rx_buffer.tail + 1) % SERIAL_BUFFER_SIZE; 13 | runSerialEvent = (rx_buffer.head != rx_buffer.tail); 14 | return c; 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/HardwareSerial.c-9.c: -------------------------------------------------------------------------------- 1 | #include "HardwareSerial.c.h" 2 | /** 3 | */ 4 | void HardwareSerial_flush(void) 5 | { 6 | // UDR is kept full while the buffer is not empty, so TXC triggers when 7 | // EMPTY && SENT 8 | 9 | // while (transmitting && ! (*_ucsra & _BV(TXC0))); 10 | // while (transmitting && ! (UARTx_SR & UARTx_SR_TC)); 11 | #ifdef USE_SPL 12 | while (transmitting && ! UARTx_GetFlagStatus(UARTx_FLAG_TC)); 13 | #else 14 | while (transmitting && !(UARTx->SR & UARTx_FLAG_TC)); 15 | #endif 16 | transmitting = 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/Serial.h: -------------------------------------------------------------------------------- 1 | #ifndef _SERIAL_H_ 2 | #define _SERIAL_H_ 3 | 4 | /* 5 | * not more than a convininience module to smoothen the transition from 6 | * real Arduino to sduino syntax for existing sketches. 7 | * 8 | * All it does is to include HardwareSerial.h, so it doesn't matter if you 9 | * include HardwareSerial or Serial into your code. 10 | * 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | // Public Methods ////////////////////////////////////////////////////////////// 19 | 20 | // Alias Definitions for a more Arduino-like look //////////////////////////// 21 | 22 | /* 23 | * all empty. 24 | * 25 | * so far, the alias definitions are done in HardwareSerial and not here. 26 | * This file is supposed to be a kind of intermediate switch to choose the 27 | * serial module depending on the configured CPU. 28 | * 29 | */ 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | main.cpp - Main loop for Arduino sketches 3 | Copyright (c) 2005-2013 Arduino Team. 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 | #include 21 | 22 | // make sure to define prototypes for all used interrupts 23 | //#include "stm8s_it.h" 24 | 25 | unsigned char runSerialEvent; 26 | 27 | int main(void) 28 | { 29 | init(); 30 | 31 | initVariant(); 32 | 33 | setup(); 34 | 35 | for (;;) { 36 | loop(); 37 | if (runSerialEvent) serialEvent(); 38 | } 39 | 40 | // return 0; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/weak_atexit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * "weak" functions to be used if no user-defined function is defined. 3 | * 4 | * This function stub is compiled into the core library. Functions from 5 | * libraries are only linked if a referenced function isnt't defined any other 6 | * object file. This way all library functions are a kind of "weak" functions. 7 | * 8 | * This function is defined in a separate source file to avoid pulling in 9 | * other unrelated definitions. 10 | */ 11 | 12 | // Declared weak in Arduino.h to allow user redefinitions. 13 | int atexit(void (*func)()) { return 0; } 14 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/weak_initVariant.c: -------------------------------------------------------------------------------- 1 | /** 2 | * "weak" functions to be used if no user-defined function is defined. 3 | * 4 | * This function stub is compiled into the core library. Functions from 5 | * libraries are only linked if a referenced function isnt't defined any other 6 | * object file. This way all library functions are a kind of "weak" functions. 7 | * 8 | * This function is defined in a separate source file to avoid pulling in 9 | * other unrelated definitions. 10 | */ 11 | 12 | // Weak empty variant initialization function. 13 | // May be redefined by variant files. 14 | void initVariant() {} 15 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/weak_serialEvent.c: -------------------------------------------------------------------------------- 1 | //#include "HardwareSerialEvent.h" 2 | 3 | /** 4 | * "weak" functions to be used if no user-defined function is defined. 5 | * 6 | * This function stub is compiled into the core library. Functions from 7 | * libraries are only linked if a referenced function isnt't defined any other 8 | * object file. This way all library functions are a kind of "weak" functions. 9 | * 10 | * This function is defined in a separate source file to avoid pulling in all 11 | * the rest of HardwareSerial, even if no serial functions are used by the 12 | * sketch. 13 | */ 14 | 15 | //unsigned char runSerialEvent; 16 | void serialEvent(void) {} 17 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring-alternate-function.c: -------------------------------------------------------------------------------- 1 | #include "wiring-header.h" 2 | 3 | /** 4 | * Helper function for STM8: Switch to the alternate pin functions 5 | * 6 | * a) flexible function: supports switching diffent AFR bits for 7 | * multiple set of pins. Not needed for stm8s103, but might be useful 8 | * for bigger parts. 9 | */ 10 | #ifdef SUPPORT_ALTERNATE_MAPPINGS 11 | /* 12 | void alternateFunction(uint8_t pin, uint8_t val) 13 | { 14 | uint16_t optionbyte; 15 | uint8_t afr; 16 | 17 | afr = digitalPinToAFR(pin); 18 | if (afr>7) return; // ignore request on invalid pin 19 | 20 | optionbyte = FLASH_ReadOptionByte(OPT->OPT2); 21 | 22 | // flip the bit if the current state differs from requested state 23 | if ( ((optionbyte & (1<OPT2, (optionbyte&0xff)^(1<> 8; 40 | // optionbyte = FLASH_ReadOptionByte(OPT->OPT2) >> 8; 41 | 42 | // flip the bit if the current state differs from requested state 43 | if ( (optionbyte & (1<<0) == 0) ^ (val==0) ) { 44 | FLASH_Unlock(FLASH_MEMTYPE_DATA); 45 | // FLASH_ProgramOptionByte(OPT->OPT2, (optionbyte&0xff)^(1<<0)); 46 | FLASH_ProgramOptionByte(0x4803, optionbyte^(1<<0)); 47 | FLASH_Lock(FLASH_MEMTYPE_DATA); 48 | } 49 | } 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring-delay.c: -------------------------------------------------------------------------------- 1 | #include "wiring-header.h" 2 | 3 | /** 4 | * Delay for the given number of milliseconds. 5 | * 6 | * Do a busy wait. Using the lower 16 bits of micros() is enough, as the 7 | * difference between the start time and the current time will never be much 8 | * higher than 1000. 9 | * 10 | * Using unsigned values is helpful here. This way value wrap-arounds between 11 | * start and now do not result in negative values but in the wanted absolute 12 | * difference. The magic of modulo-arithmethics. 13 | */ 14 | void delay(unsigned long ms) 15 | { 16 | uint16_t start, now; 17 | 18 | start = (uint16_t) micros(); // use the lower 16 bits 19 | 20 | while (ms > 0) { 21 | yield(); 22 | now = (uint16_t) micros(); // use the lower 16 bits 23 | while ( (ms > 0) && ((uint16_t)(now-start) >= 1000) ) { 24 | ms--; 25 | start += 1000; 26 | } 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring-micros.c: -------------------------------------------------------------------------------- 1 | #include "wiring-header.h" 2 | 3 | /** 4 | */ 5 | unsigned long micros() 6 | { 7 | #ifdef USE_SPL 8 | unsigned long m; 9 | uint8_t t; 10 | 11 | BEGIN_CRITICAL 12 | m = timer4_overflow_count; 13 | t = TIM4_GetCounter(); 14 | 15 | // check if a fresh update event is still pending 16 | // if (TIM4->SR1 & 0x01) 17 | if ((TIM4_GetFlagStatus(TIM4_IT_UPDATE)==SET) && (t < (T4PERIOD-1))) 18 | m++; 19 | END_CRITICAL 20 | 21 | // return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond()); 22 | // return ((m*250+t) * (64/16) ); // FIXME: use calculated value 23 | m *= T4PERIOD; 24 | m += t; 25 | // m <<= 2; 26 | m *= ((T4PRESCALER_FACTOR*1000000L)/(F_CPU)); 27 | return m; 28 | #else 29 | unsigned long m; 30 | uint8_t t; 31 | 32 | BEGIN_CRITICAL 33 | m = timer4_overflow_count; 34 | t = TIM4->CNTR; 35 | 36 | // check if a fresh update event is still pending 37 | // if (TIM4->SR1 & 0x01) 38 | if ((TIM4->SR1 & (uint8_t)TIM4_IT_UPDATE) && (t < (T4PERIOD-1))) 39 | m++; 40 | END_CRITICAL 41 | 42 | // return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond()); 43 | // return ((m*250+t) * (64/16) ); // FIXME: use calculated value 44 | m *= T4PERIOD; 45 | m += t; 46 | // m <<= 2; 47 | m *= ((T4PRESCALER_FACTOR*1000000L)/(F_CPU)); 48 | return m; 49 | #endif 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring-millis.c: -------------------------------------------------------------------------------- 1 | #include "wiring-header.h" 2 | 3 | volatile unsigned long timer4_overflow_count;// = 0; 4 | volatile unsigned long timer4_millis;// = 0; 5 | static unsigned char timer4_fract;// = 0; 6 | 7 | //void TIM4_UPD_OVF_IRQHandler(void) __interrupt(ITC_IRQ_TIM4_OVF) /* TIM4 UPD/OVF */ 8 | //void TIM4_UPD_OVF_IRQHandler(void) __interrupt(5)//FIXME 9 | INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, ITC_IRQ_TIM4_OVF) /* TIM4 UPD/OVF */ 10 | { 11 | // copy these to local variables so they can be stored in registers 12 | // (volatile variables must be read from memory on every access) 13 | unsigned long m = timer4_millis; 14 | #if (FRACT_INC != 0) 15 | unsigned char f = timer4_fract; 16 | #endif 17 | 18 | m += MILLIS_INC; 19 | #if (FRACT_INC != 0) 20 | f += FRACT_INC; 21 | if (f >= FRACT_MAX) { 22 | f -= FRACT_MAX; 23 | m += 1; 24 | } 25 | 26 | timer4_fract = f; 27 | #endif 28 | timer4_millis = m; 29 | timer4_overflow_count++; 30 | 31 | /* Clear Interrupt Pending bit */ 32 | #ifdef USE_SPL 33 | TIM4_ClearITPendingBit(TIM4_IT_UPDATE); 34 | #else 35 | TIM4->SR1 = (uint8_t)(~TIM4_IT_UPDATE); 36 | #endif 37 | } 38 | 39 | unsigned long millis() 40 | { 41 | unsigned long m; 42 | 43 | // disable interrupts while we read timer4_millis or we might get an 44 | // inconsistent value (e.g. in the middle of a write to timer4_millis) 45 | BEGIN_CRITICAL 46 | m = timer4_millis; 47 | END_CRITICAL 48 | 49 | return m; 50 | } 51 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital-tables.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_digital.c - digital input and output functions 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | 22 | Modified 28 September 2010 by Mark Sproul 23 | */ 24 | 25 | 26 | /* 27 | * compile the tables from pins_arduino.h 28 | * 29 | */ 30 | #define ARDUINO_MAIN 31 | #include "wiring_private.h" 32 | #include "pins_arduino.h" 33 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital.c-1.c: -------------------------------------------------------------------------------- 1 | #include "wiring_digital.c.h" 2 | /** 3 | * timer capture/compare mode register to control PWM mode 4 | */ 5 | const uc_p ccmrx[NUM_TIMERS]={ 6 | #ifdef NEED_TIMER_11_12 7 | TIM1->CCMR1, /* for TIMER11 */ 8 | TIM1->CCMR2, /* for TIMER12 */ 9 | #endif 10 | TIM1->CCMR3, /* for TIMER13 */ 11 | TIM1->CCMR4, /* for TIMER14 */ 12 | TIM2->CCMR1, /* for TIMER21 */ 13 | TIM2->CCMR2, /* for TIMER22 */ 14 | #ifdef NEED_TIMER_23 15 | TIM2->CCMR3, /* for TIMER23 */ 16 | #endif 17 | #ifdef NEED_TIMER_31_32 18 | TIM3->CCMR1, /* for TIMER31 */ 19 | TIM3->CCMR2 /* for TIMER32 */ 20 | #endif 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital.c-2.c: -------------------------------------------------------------------------------- 1 | #include "wiring_digital.c.h" 2 | /** 3 | * CCER register for each timer channel. 4 | * 5 | * Each 8-bit-register can contain the bits for two channels, so in addition to 6 | * the register address itself you also need the individual offset(s) of the 7 | * bit(s) you want to access. 8 | */ 9 | const uc_p ccerx[NUM_TIMERS]={ 10 | #ifdef NEED_TIMER_11_12 11 | TIM1->CCER1, /* for TIMER11 */ 12 | TIM1->CCER1, /* for TIMER12 */ 13 | #endif 14 | TIM1->CCER2, /* for TIMER13 */ 15 | TIM1->CCER2, /* for TIMER14 */ 16 | TIM2->CCER1, /* for TIMER21 */ 17 | TIM2->CCER1, /* for TIMER22 */ 18 | #ifdef NEED_TIMER_23 19 | TIM2->CCER2, /* for TIMER23 */ 20 | #endif 21 | #ifdef NEED_TIMER_31_32 22 | TIM3->CCER1, /* for TIMER31 */ 23 | TIM3->CCER1 /* for TIMER32 */ 24 | #endif 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital.c-3.c: -------------------------------------------------------------------------------- 1 | #include "wiring_digital.c.h" 2 | /** 3 | * These Bits have to be set to 0 in the timer channel's CCER 4 | * (Capture/compare enable register) to disable the output, so that the 5 | * physical pin is not driven by the timer. 6 | * 7 | * @see 8 | * RM0016 Reference Manual 9 | * STM8S Series and STM8AF Series 8-bit microcontrollers 10 | * DocID14587 Rev 14 (Oct 2017) 11 | * Table 38. Output control for complementary OCi and OCiN channels with break 12 | * feature 13 | */ 14 | const unsigned char DISABLE_TIMER_OUTP_MASK[NUM_TIMERS]={ 15 | #ifdef NEED_TIMER_11_12 16 | (1 << 0) | (1 << 2), /* for TIMER11 */ 17 | (1 << 4) | (1 << 6), /* for TIMER12 */ 18 | #endif 19 | (1 << 0) | (1 << 2), /* for TIMER13 */ 20 | (1 << 4), /* for TIMER14 */ 21 | (1 << 0), /* for TIMER21 */ 22 | (1 << 4), /* for TIMER22 */ 23 | #ifdef NEED_TIMER_23 24 | (1 << 0), /* for TIMER23 */ 25 | #endif 26 | #ifdef NEED_TIMER_31_32 27 | (1 << 0), /* for TIMER31 */ 28 | (1 << 4) /* for TIMER32 */ 29 | #endif 30 | }; 31 | 32 | 33 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital.c-5.c: -------------------------------------------------------------------------------- 1 | #include "wiring_digital.c.h" 2 | /** 3 | * handle the PWM pins 4 | */ 5 | void turnOffPWM(uint8_t timer) 6 | { 7 | // Output compare mode = 000: Frozen - The comparison between the output 8 | // compare register TIM1_CCR1 and the counter register TIM1_CNT has no 9 | // effect on the outputs. 10 | *((unsigned char *) ccmrx[timer-1]) &= ~TIM1_CCMR_OCM; 11 | 12 | // CCiE = CCiNE = 0: Output disabled (not driven by the timer) 13 | *((unsigned char *) ccerx[timer-1]) &=~ (DISABLE_TIMER_OUTP_MASK[timer-1]); 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital.c-6.c: -------------------------------------------------------------------------------- 1 | #include "wiring_digital.c.h" 2 | /** 3 | * set an output value for a pin 4 | */ 5 | void digitalWrite(uint8_t pin, uint8_t val) 6 | { 7 | uint8_t timer = digitalPinToTimer(pin); 8 | uint8_t bit = digitalPinToBitMask(pin); 9 | uint8_t port = digitalPinToPort(pin); 10 | volatile uint8_t *out; 11 | 12 | if (port == NOT_A_PIN) return; 13 | 14 | // If the pin that support PWM output, we need to turn it off 15 | // before doing a digital write. 16 | if (timer != NOT_ON_TIMER) turnOffPWM(timer); 17 | 18 | out = portOutputRegister(port); 19 | 20 | BEGIN_CRITICAL 21 | 22 | if (val == LOW) { 23 | *out &= ~bit; 24 | } else { 25 | *out |= bit; 26 | } 27 | 28 | END_CRITICAL 29 | } 30 | 31 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital.c-7.c: -------------------------------------------------------------------------------- 1 | #include "wiring_digital.c.h" 2 | /** 3 | * read a pin value 4 | */ 5 | int digitalRead(uint8_t pin) 6 | { 7 | uint8_t timer = digitalPinToTimer(pin); 8 | uint8_t bit = digitalPinToBitMask(pin); 9 | uint8_t port = digitalPinToPort(pin); 10 | 11 | if (port == NOT_A_PIN) return LOW; 12 | 13 | // If the pin that support PWM output, we need to turn it off 14 | // before getting a digital reading. 15 | if (timer != NOT_ON_TIMER) turnOffPWM(timer); 16 | 17 | if (*portInputRegister(port) & bit) return HIGH; 18 | return LOW; 19 | } 20 | -------------------------------------------------------------------------------- /sduino/stm8/cores/sduino/wiring_digital.c.h: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_digital.c - digital input and output functions 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | 22 | Modified 28 September 2010 by Mark Sproul 23 | */ 24 | 25 | #include "wiring_private.h" 26 | #include "pins_arduino.h" 27 | 28 | 29 | 30 | /* this typedef is a SDCC wordaround. 31 | * Defining this a type instead of defining an array of (unsigned char *) 32 | * keeps SDCC from storing the array in the xinit segment and copy it to RAM 33 | * at runtime. 34 | */ 35 | typedef unsigned char *uc_p; 36 | 37 | extern const uc_p ccmrx[NUM_TIMERS]; 38 | extern const uc_p ccerx[NUM_TIMERS]; 39 | extern const unsigned char DISABLE_TIMER_OUTP_MASK[NUM_TIMERS]; 40 | void turnOffPWM(uint8_t timer); 41 | 42 | 43 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_clear/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Clear 3 | * 4 | * Sets all of the bytes of the EEPROM to 0. 5 | * Please see eeprom_iteration for a more in depth 6 | * look at how to traverse the EEPROM. 7 | * 8 | * Modified to C for use with SDuino by Michael Mayer 2018 9 | * 10 | * This example code is in the public domain. 11 | */ 12 | 13 | #include 14 | 15 | void setup() { 16 | // initialize the LED pin as an output. 17 | pinMode(LED_BUILTIN, OUTPUT); 18 | 19 | /*** 20 | Iterate through each byte of the EEPROM storage. 21 | 22 | Larger STM8 processors have larger EEPROM sizes, E.g: 23 | - STM8S003: 128B EEPROM storage. 24 | - STM8S103: 640B EEPROM storage. 25 | - STM8S105: 1kB EEPROM storage. 26 | - STM8S208S: 1.5kB EEPROM storage. 27 | - STM8S208R: 2kB EEPROM storage. 28 | 29 | Rather than hard-coding the length, you should use the pre-provided length function. 30 | This will make your code portable to all STM8 processors. 31 | ***/ 32 | 33 | for (int i = 0 ; i < EEPROM_length() ; i++) { 34 | EEPROM_write(i, 0); 35 | } 36 | 37 | // turn the LED on when we're done 38 | digitalWrite(LED_BUILTIN, HIGH); 39 | } 40 | 41 | void loop() { 42 | /** Empty loop. **/ 43 | } 44 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_crc/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_get/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_iteration/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | eeprom_iteration example. 3 | 4 | A set of example snippets highlighting the 5 | simplest methods for traversing the EEPROM. 6 | 7 | Running this sketch is not necessary, this is 8 | simply highlighting certain programming methods. 9 | 10 | Written by Christopher Andrews 2015 11 | Modified to C for use with SDuino by Michael Mayer 2018 12 | Released under MIT licence. 13 | ***/ 14 | 15 | #include 16 | 17 | void setup() { 18 | 19 | // unlock the EEPROM first to enable write access 20 | eeprom_unlock(); 21 | 22 | /*** 23 | Iterate the EEPROM using a for loop. 24 | ***/ 25 | 26 | for (int index = 0 ; index < EEPROM_length() ; index++) { 27 | 28 | //Add one to each cell in the EEPROM 29 | EEPROM_cell[ index ] += 1; 30 | } 31 | 32 | /*** 33 | Iterate the EEPROM using a while loop. 34 | ***/ 35 | 36 | int index = 0; 37 | 38 | while (index < EEPROM_length()) { 39 | 40 | //Add one to each cell in the EEPROM 41 | EEPROM_cell[ index ] += 1; 42 | index++; 43 | } 44 | 45 | /*** 46 | Iterate the EEPROM using a do-while loop. 47 | ***/ 48 | 49 | int idx = 0; //Used 'idx' to avoid name conflict with 'index' above. 50 | 51 | do { 52 | 53 | //Add one to each cell in the EEPROM 54 | EEPROM_cell[ idx ] += 1; 55 | idx++; 56 | } while (idx < EEPROM_length()); 57 | 58 | // re-lock the EEPROM again. Not strictly needed, but usually a good idea. 59 | eeprom_lock(); 60 | 61 | } //End of setup function. 62 | 63 | void loop() {} -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_put/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_read/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_update/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/examples/eeprom_write/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For EEPROM 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | EEPROM KEYWORD1 10 | EERef KEYWORD1 11 | EEPtr KEYWORD2 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | 17 | EEPROM_read KEYWORD2 18 | EEPROM_write KEYWORD2 19 | EEPROM_update KEYWORD2 20 | 21 | EEPROM_put KEYWORD2 22 | EEPROM_get KEYWORD2 23 | 24 | EEPROM_begin KEYWORD2 25 | EEPROM_end KEYWORD2 26 | EEPROM_length KEYWORD2 27 | 28 | eeprom_unlock KEYWORD2 29 | eeprom_lock KEYWORD2 30 | eeprom_is_unlocked KEYWORD2 31 | eeprom_is_ready KEYWORD2 32 | 33 | eeprom_read_block KEYWORD2 34 | eeprom_write_block KEYWORD2 35 | eeprom_update_block KEYWORD2 36 | 37 | ####################################### 38 | # Constants (LITERAL1) 39 | ####################################### 40 | 41 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/library.properties: -------------------------------------------------------------------------------- 1 | name=EEPROM 2 | version=1.0 3 | author=Michael Mayer 4 | maintainer=SDuino 5 | sentence=Enables reading and writing to the permanent board storage. 6 | paragraph=This library allows to read and write data in a memory type, the EEPROM, that keeps its content also when the board is powered off. The amount of EEPROM available depends on the microcontroller type. 7 | category=Data Storage 8 | url=https://tenbaht.github.io/sduino/api/EEPROM 9 | architectures=stm8 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/src/EEPROM_write.c: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROM.h - EEPROM library 3 | Plain-C version for SDuino by Michael Mayer 2018. 4 | 5 | This is a rewrite from scratch. The basic API is inspired by the 6 | Arduino EEPROM library, but none of the operator overloading functions 7 | can be ported in any sensible way to C. 8 | 9 | Original Copyright (c) 2006 David A. Mellis. All right reserved. 10 | New version by Christopher Andrews 2015. 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #include "EEPROM.h" 28 | 29 | 30 | /* --- Arduino-like interface -------------------------------------------- */ 31 | 32 | void EEPROM_write( int idx, uint8_t val ) 33 | { 34 | eeprom_unlock(); 35 | if (eeprom_is_unlocked()) 36 | { 37 | // write only after a successful unlock. 38 | EERef(idx) = val; 39 | // re-lock the EEPROM again. 40 | FLASH->IAPSR &= FLASH_FLAG_DUL; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/src/utility/eeprom_lock.c: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROM.h - EEPROM library 3 | Plain-C version for SDuino by Michael Mayer 2018. 4 | 5 | This is a rewrite from scratch. The basic API is inspired by the 6 | Arduino EEPROM library, but none of the operator overloading functions 7 | can be ported in any sensible way to C. 8 | 9 | Original Copyright (c) 2006 David A. Mellis. All right reserved. 10 | New version by Christopher Andrews 2015. 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #include "EEPROM.h" 28 | 29 | 30 | void eeprom_lock(void) 31 | { 32 | // re-lock the EEPROM again. 33 | FLASH->IAPSR &= FLASH_FLAG_DUL; 34 | } 35 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/EEPROM/src/utility/eeprom_unlock.c: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROM.h - EEPROM library 3 | Plain-C version for SDuino by Michael Mayer 2018. 4 | 5 | This is a rewrite from scratch. The basic API is inspired by the 6 | Arduino EEPROM library, but none of the operator overloading functions 7 | can be ported in any sensible way to C. 8 | 9 | Original Copyright (c) 2006 David A. Mellis. All right reserved. 10 | New version by Christopher Andrews 2015. 11 | 12 | This library is free software; you can redistribute it and/or 13 | modify it under the terms of the GNU Lesser General Public 14 | License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. 16 | 17 | This library is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #include "EEPROM.h" 28 | 29 | 30 | void eeprom_unlock(void) 31 | { 32 | // it might be easier to just unlock it, independed of the status 33 | if (!eeprom_is_unlocked()) 34 | { 35 | // EEPROM still locked. Unlock first. 36 | FLASH->DUKR = FLASH_RASS_KEY2; 37 | FLASH->DUKR = FLASH_RASS_KEY1; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/empty.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/empty.h -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | AnalogReadSerial 3 | 4 | Reads an analog input on pin 0, prints the result to the Serial Monitor. 5 | Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu). 6 | Attach the center pin of a potentiometer to pin A0, and the outside pins to +3.3V and ground. 7 | 8 | This example code is in the public domain. 9 | 10 | http://www.arduino.cc/en/Tutorial/AnalogReadSerial 11 | */ 12 | 13 | #include 14 | 15 | // the setup routine runs once when you press reset: 16 | void setup() { 17 | // initialize serial communication at 9600 bits per second: 18 | Serial_begin(9600); 19 | } 20 | 21 | // the loop routine runs over and over again forever: 22 | void loop() { 23 | // read the input on analog pin 0: 24 | int sensorValue = analogRead(A0); 25 | // print out the value you read: 26 | Serial_println_u(sensorValue); 27 | delay(1); // delay in between reads for stability 28 | } 29 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.txt: -------------------------------------------------------------------------------- 1 | Read a potentiometer, print its state out to the Arduino Serial Monitor. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/AnalogReadSerial/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/BareMinimum/BareMinimum.ino: -------------------------------------------------------------------------------- 1 | void setup() { 2 | // put your setup code here, to run once: 3 | 4 | } 5 | 6 | void loop() { 7 | // put your main code here, to run repeatedly: 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/BareMinimum/BareMinimum.txt: -------------------------------------------------------------------------------- 1 | The bare minimum of code needed to start an Arduino sketch. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/BareMinimum/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | 4 | Turns an LED on for one second, then off for one second, repeatedly. 5 | 6 | Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 7 | it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to 8 | the correct LED pin independent of which board is used. 9 | If you want to know what pin the on-board LED is connected to on your Arduino 10 | model, check the Technical Specs of your board at: 11 | https://www.arduino.cc/en/Main/Products 12 | 13 | modified 8 May 2014 14 | by Scott Fitzgerald 15 | modified 2 Sep 2016 16 | by Arturo Guadalupi 17 | modified 8 Sep 2016 18 | by Colby Newman 19 | 20 | This example code is in the public domain. 21 | 22 | http://www.arduino.cc/en/Tutorial/Blink 23 | */ 24 | 25 | // the setup function runs once when you press reset or power the board 26 | void setup() { 27 | // initialize digital pin LED_BUILTIN as an output. 28 | pinMode(LED_BUILTIN, OUTPUT); 29 | } 30 | 31 | // the loop function runs over and over again forever 32 | void loop() { 33 | digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) 34 | delay(1000); // wait for a second 35 | digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 36 | delay(1000); // wait for a second 37 | } 38 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/Blink/Blink.txt: -------------------------------------------------------------------------------- 1 | Turn an LED on and off. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/Blink/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | DigitalReadSerial 3 | 4 | Reads a digital input on pin 2, prints the result to the Serial Monitor 5 | 6 | This example code is in the public domain. 7 | 8 | http://www.arduino.cc/en/Tutorial/DigitalReadSerial 9 | */ 10 | 11 | #include 12 | 13 | // digital pin 2 has a pushbutton attached to it. Give it a name: 14 | int pushButton = 2; 15 | 16 | // the setup routine runs once when you press reset: 17 | void setup() { 18 | // initialize serial communication at 9600 bits per second: 19 | Serial_begin(9600); 20 | // make the pushbutton's pin an input: 21 | pinMode(pushButton, INPUT); 22 | } 23 | 24 | // the loop routine runs over and over again forever: 25 | void loop() { 26 | // read the input pin: 27 | int buttonState = digitalRead(pushButton); 28 | // print out the state of the button: 29 | Serial_println_u(buttonState); 30 | delay(1); // delay in between reads for stability 31 | } 32 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.txt: -------------------------------------------------------------------------------- 1 | Read a switch, print the state out to the Arduino Serial Monitor. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/DigitalReadSerial/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/Fade/Fade.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Fade 3 | 4 | This example shows how to fade an LED on pin 5 using the analogWrite() 5 | function. 6 | 7 | The analogWrite() function uses PWM, so if you want to change the pin you're 8 | using, be sure to use another PWM capable pin. On most Arduino, the PWM pins 9 | are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11. 10 | 11 | This example code is in the public domain. 12 | 13 | http://www.arduino.cc/en/Tutorial/Fade 14 | */ 15 | 16 | int led = 5; // the PWM pin the LED is attached to 17 | int brightness = 0; // how bright the LED is 18 | int fadeAmount = 5; // how many points to fade the LED by 19 | 20 | // the setup routine runs once when you press reset: 21 | void setup() { 22 | // declare pin 9 to be an output: 23 | pinMode(led, OUTPUT); 24 | } 25 | 26 | // the loop routine runs over and over again forever: 27 | void loop() { 28 | // set the brightness of pin 9: 29 | analogWrite(led, brightness); 30 | 31 | // change the brightness for next time through the loop: 32 | brightness = brightness + fadeAmount; 33 | 34 | // reverse the direction of the fading at the ends of the fade: 35 | if (brightness <= 0 || brightness >= 255) { 36 | fadeAmount = -fadeAmount; 37 | } 38 | // wait for 30 milliseconds to see the dimming effect 39 | delay(30); 40 | } 41 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/Fade/Fade.txt: -------------------------------------------------------------------------------- 1 | Demonstrates the use of analogWrite() to fade an LED. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/Fade/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/ReadAnalogVoltage/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ReadAnalogVoltage 3 | 4 | Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor. 5 | Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu). 6 | Attach the center pin of a potentiometer to pin A0, and the outside pins to +3.3V and ground. 7 | 8 | This example code is in the public domain. 9 | 10 | http://www.arduino.cc/en/Tutorial/ReadAnalogVoltage 11 | */ 12 | 13 | #include 14 | 15 | // the setup routine runs once when you press reset: 16 | void setup() { 17 | // initialize serial communication at 9600 bits per second: 18 | Serial_begin(9600); 19 | } 20 | 21 | // the loop routine runs over and over again forever: 22 | void loop() { 23 | // read the input on analog pin 0: 24 | int sensorValue = analogRead(A0); 25 | // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.3V): 26 | float voltage = sensorValue * (3.3 / 1023.0); 27 | // print out the value you read: 28 | Serial_println_f(voltage); 29 | } 30 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.txt: -------------------------------------------------------------------------------- 1 | Reads an analog input and prints the voltage to the Serial Monitor. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.txt: -------------------------------------------------------------------------------- 1 | Blinking an LED without using the delay() function. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/BlinkWithoutDelay/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Button/Button.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Button 3 | 4 | Turns on and off a light emitting diode(LED) connected to digital pin 3, 5 | when pressing a pushbutton attached to pin 2. 6 | 7 | The circuit: 8 | - LED attached from pin 3 to VCC 9 | - pushbutton attached to pin 2 from +5V 10 | - 10K resistor attached to pin 2 from ground 11 | 12 | - Note: on the STM8S103 breakout board there is already an LED on the board 13 | attached to pin 3. 14 | 15 | created 2005 16 | by DojoDave 17 | modified 30 Aug 2011 18 | by Tom Igoe 19 | modified 13 Feb 2017 for use with sduino 20 | by Michael Mayer 21 | 22 | This example code is in the public domain. 23 | 24 | http://www.arduino.cc/en/Tutorial/Button 25 | */ 26 | 27 | // constants won't change. They're used here to set pin numbers: 28 | const int buttonPin = 2; // the number of the pushbutton pin 29 | const int ledPin = 3; // the number of the LED pin 30 | 31 | // variables will change: 32 | int buttonState = 0; // variable for reading the pushbutton status 33 | 34 | void setup() { 35 | // initialize the LED pin as an output: 36 | pinMode(ledPin, OUTPUT); 37 | // initialize the pushbutton pin as an input: 38 | pinMode(buttonPin, INPUT); 39 | } 40 | 41 | void loop() { 42 | // read the state of the pushbutton value: 43 | buttonState = digitalRead(buttonPin); 44 | 45 | // check if the pushbutton is pressed. If it is, the buttonState is HIGH: 46 | if (buttonState == HIGH) { 47 | // turn LED on: 48 | digitalWrite(ledPin, HIGH); 49 | } else { 50 | // turn LED off: 51 | digitalWrite(ledPin, LOW); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Button/Button.txt: -------------------------------------------------------------------------------- 1 | Use a pushbutton to control an LED. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Button/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Debounce/Debounce.txt: -------------------------------------------------------------------------------- 1 | Read a pushbutton, filtering noise. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Debounce/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Debounce/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Debounce/button.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Debounce/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/02.Digital/Debounce/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Input Pull-up Serial 3 | 4 | This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a digital 5 | input on pin 2 and prints the results to the Serial Monitor. 6 | 7 | The circuit: 8 | - momentary switch attached from pin 2 to ground 9 | - built-in LED on pin 3 10 | 11 | Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal 12 | 20K-ohm resistor is pulled to 3.3V. This configuration causes the input to read 13 | HIGH when the switch is open, and LOW when it is closed. 14 | 15 | created 14 Mar 2012 16 | by Scott Fitzgerald 17 | modified 13 Feb 2017 for use with sduino 18 | by Michael Mayer 19 | 20 | This example code is in the public domain. 21 | 22 | http://www.arduino.cc/en/Tutorial/InputPullupSerial 23 | */ 24 | 25 | #include 26 | 27 | void setup() { 28 | //start serial connection 29 | Serial_begin(9600); 30 | //configure pin 2 as an input and enable the internal pull-up resistor 31 | pinMode(2, INPUT_PULLUP); 32 | pinMode(3, OUTPUT); 33 | 34 | } 35 | 36 | void loop() { 37 | //read the pushbutton value into a variable 38 | int sensorVal = digitalRead(2); 39 | //print out the value of the pushbutton 40 | Serial_println_u(sensorVal); 41 | 42 | // Keep in mind the pull-up means the pushbutton's logic is inverted. It goes 43 | // HIGH when it's open, and LOW when it's pressed. Turn on pin 3 when the 44 | // button's pressed, and off when it's not: 45 | if (sensorVal == HIGH) { 46 | digitalWrite(3, LOW); 47 | } else { 48 | digitalWrite(3, HIGH); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.txt: -------------------------------------------------------------------------------- 1 | Demonstrates the use of INPUT_PULLUP with pinMode(). -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/DigitalInputPullup/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/DigitalInputPullup/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/02.Digital/DigitalInputPullup/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/DigitalInputPullup/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/02.Digital/DigitalInputPullup/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/StateChangeDetection/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/StateChangeDetection/StateChangeDetection.txt: -------------------------------------------------------------------------------- 1 | Counting the number of button pushes. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/StateChangeDetection/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/02.Digital/StateChangeDetection/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/02.Digital/StateChangeDetection/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/02.Digital/StateChangeDetection/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.txt: -------------------------------------------------------------------------------- 1 | Read an analog input pin, map the result, and then use that data to dim or brighten an LED. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInOutSerial/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInOutSerial/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInOutSerial/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInOutSerial/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInOutSerial/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInput/AnalogInput.txt: -------------------------------------------------------------------------------- 1 | Use a potentiometer to control the blinking of an LED. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInput/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInput/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInput/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInput/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/AnalogInput/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Calibration/Calibration.txt: -------------------------------------------------------------------------------- 1 | Define a maximum and minimum for expected analog sensor values. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Calibration/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Calibration/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Calibration/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Calibration/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Calibration/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Fading/Fading.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Fading 3 | 4 | This example shows how to fade an LED using the analogWrite() function. 5 | 6 | The circuit: 7 | - LED attached from digital pin 9 to ground. 8 | 9 | created 1 Nov 2008 10 | by David A. Mellis 11 | modified 30 Aug 2011 12 | by Tom Igoe 13 | modified 28 Feb 2017 for use with sduino 14 | by Michael Mayer 15 | 16 | This example code is in the public domain. 17 | 18 | http://www.arduino.cc/en/Tutorial/Fading 19 | */ 20 | 21 | int ledPin = 9; // LED connected to digital pin 9 22 | 23 | void setup() { 24 | // nothing happens in setup 25 | } 26 | 27 | void loop() { 28 | // fade in from min to max in increments of 5 points: 29 | for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) { 30 | // sets the value (range from 0 to 255): 31 | analogWrite(ledPin, fadeValue); 32 | // wait for 30 milliseconds to see the dimming effect 33 | delay(30); 34 | } 35 | 36 | // fade out from max to min in increments of 5 points: 37 | for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) { 38 | // sets the value (range from 0 to 255): 39 | analogWrite(ledPin, fadeValue); 40 | // wait for 30 milliseconds to see the dimming effect 41 | delay(30); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Fading/Fading.txt: -------------------------------------------------------------------------------- 1 | Use an analog output (PWM pin) to fade an LED. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Fading/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Fading/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Fading/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Fading/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Fading/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Smoothing/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Smoothing/Smoothing.txt: -------------------------------------------------------------------------------- 1 | Smooth multiple readings of an analog input. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Smoothing/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Smoothing/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Smoothing/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/03.Analog/Smoothing/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/ASCIITable/ASCIITable.txt: -------------------------------------------------------------------------------- 1 | Demonstrates Arduino's advanced serial output functions. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/ASCIITable/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Dimmer/Dimmer.txt: -------------------------------------------------------------------------------- 1 | Move the mouse to change the brightness of an LED. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Dimmer/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Dimmer/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Dimmer/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Dimmer/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Dimmer/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Graph/Graph.txt: -------------------------------------------------------------------------------- 1 | Send data to the computer and graph it in Processing. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Graph/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Graph/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Graph/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Graph/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/Graph/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponse/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponse/SerialCallResponse.txt: -------------------------------------------------------------------------------- 1 | Send multiple variables using a call-and-response (handshaking) method. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponse/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponse/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponse/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponse/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponseASCII/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.txt: -------------------------------------------------------------------------------- 1 | Send multiple variables using a call-and-response (handshaking) method, and ASCII-encode the values before sending. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponseASCII/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponseASCII/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponseASCII/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/04.Communication/SerialCallResponseASCII/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/06.Sensors/Ping/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/06.Sensors/Ping/Ping.txt: -------------------------------------------------------------------------------- 1 | Detecting objects with an ultrasonic range finder. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/06.Sensors/Ping/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/06.Sensors/Ping/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/06.Sensors/Ping/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/06.Sensors/Ping/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/07.Display/barGraph/LEDBarGraph.txt: -------------------------------------------------------------------------------- 1 | How to make an LED bar graph. -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/07.Display/barGraph/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/07.Display/barGraph/layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/07.Display/barGraph/layout.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/Generic_Examples/examples/07.Display/barGraph/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/Generic_Examples/examples/07.Display/barGraph/schematic.png -------------------------------------------------------------------------------- /sduino/stm8/libraries/I2C/examples/HMC5883L/HMC5883L.pde: -------------------------------------------------------------------------------- 1 | /******************************************* 2 | Sample sketch that configures an HMC5883L 3 axis 3 | magnetometer to continuous mode and reads back 4 | the three axis of data. 5 | Code compiles to a size of 1500 bytes 6 | Equivalent Wire Library code compiles to 2032 bytes 7 | *******************************************/ 8 | 9 | #include 10 | 11 | #define HMC5883L 0x1E 12 | 13 | int x = 0; 14 | int y = 0; 15 | int z = 0; 16 | 17 | 18 | void setup() 19 | { 20 | I2C_begin(); 21 | I2C_write_c(HMC5883L,0x02,0x00); //configure device for continuous mode 22 | } 23 | 24 | void loop() 25 | { 26 | I2C_read(HMC5883L,0x03,6); //read 6 bytes (x,y,z) from the device 27 | x = I2C_receive() << 8; 28 | x |= I2C_receive(); 29 | y = I2C_receive() << 8; 30 | y |= I2C_receive(); 31 | z = I2C_receive() << 8; 32 | z |= I2C_receive(); 33 | } 34 | 35 | 36 | /* Wire library equivalent would be this 37 | 38 | //#include 39 | 40 | #define HMC5883L 0x1E 41 | 42 | int x = 0; 43 | int y = 0; 44 | int z = 0; 45 | 46 | 47 | void setup() 48 | { 49 | Wire.begin(); 50 | Wire.beginTransmission(HMC5883L); 51 | Wire.send(0x02); 52 | Wire.send(0x00); 53 | Wire.endTransmission(); 54 | } 55 | 56 | void loop() 57 | { 58 | Wire.beginTransmission(HMC5883L); 59 | Wire.send(0x03); 60 | Wire.endTransmission(); 61 | Wire.requestFrom(HMC5883L,6); 62 | x = Wire.receive() << 8; 63 | x |= Wire.receive(); 64 | y = Wire.receive() << 8; 65 | y |= Wire.receive(); 66 | z = Wire.receive() << 8; 67 | z |= Wire.receive(); 68 | } 69 | 70 | ********************************************/ 71 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/I2C/examples/busscan/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/I2C/examples/busscan/busscan.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Scan the I2C bus for connected devices. 3 | * 4 | * The output is on the serial output. 5 | * 6 | * This is in the public domain 7 | * (c) 2018 M. Mayer 8 | */ 9 | 10 | #include "I2C.h" 11 | 12 | void setup() 13 | { 14 | Serial_begin(9600); 15 | Serial_println_s("Scanning the I2C bus for connected devices:"); 16 | 17 | I2C_begin(); 18 | I2C_scan(); 19 | 20 | Serial_println_s("Scan finished. "); 21 | } 22 | 23 | void loop() 24 | { 25 | // Do nothing here... 26 | } 27 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/I2C/examples/pcf8574/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/I2C/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For I2C 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | I2C KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | 14 | begin KEYWORD2 15 | end KEYWORD2 16 | timeOut KEYWORD2 17 | setSpeed KEYWORD2 18 | pullup KEYWORD2 19 | scan KEYWORD2 20 | write KEYWORD2 21 | read KEYWORD2 22 | available KEYWORD2 23 | receive KEYWORD2 24 | 25 | ####################################### 26 | # Instances (KEYWORD2) 27 | ####################################### 28 | 29 | I2c KEYWORD2 30 | 31 | ####################################### 32 | # Constants (LITERAL1) 33 | ####################################### -------------------------------------------------------------------------------- /sduino/stm8/libraries/LCD_BTHQ21605V/LCD_BTHQ21605V.h: -------------------------------------------------------------------------------- 1 | /** 2 | \file LCD_BTHQ21605V.h 3 | 4 | \author G. Icking-Konert 5 | \date 2018-10-14 6 | \version 0.1 7 | 8 | \brief declaration of I2C routines for BTHQ21605V LCD 9 | 10 | declaration of LCD routines for 2x16 Batron BTHQ21605V-COG-FSRE-I2C (Farnell: 1220409). 11 | Control is via I2C, reset is via any digital pin (active high) 12 | */ 13 | 14 | /*----------------------------------------------------------------------------- 15 | MODULE DEFINITION FOR MULTIPLE INCLUSION 16 | -----------------------------------------------------------------------------*/ 17 | #ifndef _LCD_BTHQ21605V_H_ 18 | #define _LCD_BTHQ21605V_H_ 19 | 20 | #include 21 | #include 22 | #include "Arduino.h" 23 | #include 24 | 25 | 26 | /*----------------------------------------------------------------------------- 27 | DECLARATION OF GLOBAL FUNCTIONS 28 | -----------------------------------------------------------------------------*/ 29 | 30 | /// initialize LCD screen 31 | void lcd_begin(uint8_t addrI2C, GPIO_TypeDef *rstPort, uint8_t rstPin); 32 | 33 | /// clear LCD screen 34 | void lcd_clear(void); 35 | 36 | /// print string to LCD 37 | uint8_t lcd_print_s(uint8_t line, uint8_t col, uint8_t *str); 38 | 39 | /// print number to LCD display 40 | uint8_t lcd_print_i(uint8_t line, uint8_t col, int value); 41 | 42 | 43 | /*----------------------------------------------------------------------------- 44 | END OF MODULE DEFINITION FOR MULTIPLE INLUSION 45 | -----------------------------------------------------------------------------*/ 46 | #endif // _LCD_BTHQ21605V_H_ 47 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LCD_BTHQ21605V/examples/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /******************************************* 2 | Sample sketch that prints text to a 2x16 LCD 3 | (Batron BTHQ21605V-COG-FSRE-I2C; Farnell: 1220409) 4 | via I2C. 5 | Configuration 6 | - connect SCL/SDA pins (with pull-ups) 7 | - connect LCD POR pin to STM8 PE3 (see lcd_reset()) 8 | - set address to 0x3B (see define) 9 | *******************************************/ 10 | 11 | #include 12 | 13 | #define ADDR 0x3B // I2C address of LCD 14 | 15 | 16 | void setup() 17 | { 18 | // init LCD 19 | lcd_begin(ADDR, GPIOE, 3); 20 | 21 | // print greeting 22 | lcd_print_s(1, 6, "hello"); 23 | lcd_print_s(2, 6, "world"); 24 | delay(2000); 25 | lcd_clear(); 26 | 27 | } // setup 28 | 29 | 30 | void loop() 31 | { 32 | lcd_clear(); 33 | lcd_print_s(1, 1, "time: "); 34 | lcd_print_i(1, 7, millis()/1000L); 35 | lcd_print_s(2, 5, "seconds"); 36 | delay(1000); 37 | 38 | } // loop 39 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LCD_BTHQ21605V/extras/LCD_datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/libraries/LCD_BTHQ21605V/extras/LCD_datasheet.pdf -------------------------------------------------------------------------------- /sduino/stm8/libraries/LCD_BTHQ21605V/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For LCD_BTHQ21605V 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | LCD KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | 14 | lcd_begin KEYWORD2 15 | lcd_clear KEYWORD2 16 | lcd_print_s KEYWORD2 17 | lcd_print_i KEYWORD2 18 | 19 | ####################################### 20 | # Instances (KEYWORD2) 21 | ####################################### 22 | 23 | LCD KEYWORD2 24 | 25 | ####################################### 26 | # Constants (LITERAL1) 27 | ####################################### 28 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/README.adoc: -------------------------------------------------------------------------------- 1 | = Liquid Crystal Library for Arduino = 2 | 3 | This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. 4 | 5 | For more information about this library please visit us at 6 | http://www.arduino.cc/en/Reference/LiquidCrystal 7 | 8 | == License == 9 | 10 | Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. 11 | Copyright (c) 2010 Arduino LLC. All right reserved. 12 | 13 | This library is free software; you can redistribute it and/or 14 | modify it under the terms of the GNU Lesser General Public 15 | License as published by the Free Software Foundation; either 16 | version 2.1 of the License, or (at your option) any later version. 17 | 18 | This library is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public 24 | License along with this library; if not, write to the Free Software 25 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/Autoscroll/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/Blink/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/Cursor/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/CustomCharacter/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/Display/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/HelloWorld/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/Scroll/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/SerialDisplay/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/TextDirection/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/examples/setCursor/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For LiquidCrystal 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | LiquidCrystal KEYWORD1 LiquidCrystal 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | clear KEYWORD2 17 | home KEYWORD2 18 | print KEYWORD2 19 | setCursor KEYWORD2 20 | cursor KEYWORD2 21 | noCursor KEYWORD2 22 | blink KEYWORD2 23 | noBlink KEYWORD2 24 | display KEYWORD2 25 | noDisplay KEYWORD2 26 | autoscroll KEYWORD2 27 | noAutoscroll KEYWORD2 28 | leftToRight KEYWORD2 29 | rightToLeft KEYWORD2 30 | scrollDisplayLeft KEYWORD2 31 | scrollDisplayRight KEYWORD2 32 | createChar KEYWORD2 33 | setRowOffsets KEYWORD2 34 | 35 | ####################################### 36 | # Constants (LITERAL1) 37 | ####################################### 38 | 39 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal/library.properties: -------------------------------------------------------------------------------- 1 | name=LiquidCrystal 2 | version=1.0.5 3 | author=Arduino, Adafruit 4 | maintainer=Arduino 5 | sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). 6 | paragraph=This library allows an Arduino/Genuino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). 7 | category=Display 8 | url=http://www.arduino.cc/en/Reference/LiquidCrystal 9 | architectures=* 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/README.md: -------------------------------------------------------------------------------- 1 | # Installation # 2 | Create a new folder called "LiquidCrystal_I2C" under the folder named "libraries" in your Arduino sketchbook folder. 3 | Create the folder "libraries" in case it does not exist yet. Place all the files in the "LiquidCrystal_I2C" folder. 4 | 5 | # Usage # 6 | To use the library in your own sketch, select it from *Sketch > Import Library*. 7 | 8 | ------------------------------------------------------------------------------------------------------------------- 9 | This library is based on work done by DFROBOT (www.dfrobot.com). -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/examples/BlinkingCursor/BlinkingCursor.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Demonstrates the use of lcd_Blink() and lcd_noBlink() 3 | * 4 | * modified for use with SDuino 5 | * 25.10.2018 by Michael Mayer 6 | */ 7 | #include 8 | #include 9 | 10 | // Set the LCD address to 0x27 for a 16 chars and 2 line display 11 | LiquidCrystal_I2C (lcd,0x27, 16, 2); 12 | 13 | void setup() 14 | { 15 | // initialize the LCD 16 | lcd_begin(); 17 | } 18 | 19 | void loop() 20 | { 21 | bool blinking = true; 22 | lcd_cursor(); 23 | 24 | while (1) { 25 | if (blinking) { 26 | lcd_clear(); 27 | lcd_print_s("No cursor blink"); 28 | lcd_noBlink(); 29 | blinking = false; 30 | } else { 31 | lcd_clear(); 32 | lcd_print_s("Cursor blink"); 33 | lcd_blink(); 34 | blinking = true; 35 | } 36 | delay(4000); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/examples/BlinkingCursor/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/examples/CustomChars/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/examples/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // The PCF8574 exists in three variants using two different I2C address ranges: 5 | // 6 | // PCF8574 and PCF8574T (most common): 0x20..0x27, typ. 0x27 7 | // PCF8574A: 0x38..0x3f, typ. 0x3f 8 | 9 | // Set the LCD address to 0x27 for a 16 chars and 2 line display 10 | #define LCD_ADDR 0x27 11 | 12 | LiquidCrystal_I2C(lcd, 0x27, 16, 2); 13 | 14 | void setup() 15 | { 16 | // initialize the LCD 17 | lcd_begin(); 18 | 19 | // Turn on the blacklight and print a message. 20 | lcd_backlight(); 21 | lcd_print_s("Hello, world!"); 22 | } 23 | 24 | void loop() 25 | { 26 | lcd_setCursor(0, 1); 27 | lcd_print_u(millis() / 1000); 28 | } 29 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/examples/HelloWorld/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/examples/SerialDisplay/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/examples/SerialDisplay/SerialDisplay.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Displays text sent over the serial port (e.g. from the Serial Monitor) on 3 | * an attached LCD. 4 | * 5 | * modified for use with SDuino 6 | * 25.10.2018 by Michael Mayer 7 | */ 8 | #include 9 | #include 10 | 11 | // Set the LCD address to 0x27 for a 16 chars and 2 line display 12 | LiquidCrystal_I2C (lcd,0x27, 16, 2); 13 | 14 | void setup() 15 | { 16 | lcd_begin(); 17 | lcd_backlight(); 18 | 19 | // Initialize the serial port at a speed of 9600 baud 20 | Serial_begin(9600); 21 | } 22 | 23 | void loop() 24 | { 25 | // If characters arrived over the serial port... 26 | if (Serial_available()) { 27 | // Wait a bit for the entire message to arrive 28 | delay(100); 29 | // Clear the screen 30 | lcd_clear(); 31 | 32 | // Write all characters received with the serial port to the LCD. 33 | while (Serial_available() > 0) { 34 | lcd_write(Serial_read()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/keywords.txt: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Syntax Coloring Map For LiquidCrystal_I2C 3 | ########################################### 4 | 5 | ########################################### 6 | # Datatypes (KEYWORD1) 7 | ########################################### 8 | 9 | LiquidCrystal_I2C KEYWORD1 10 | 11 | ########################################### 12 | # Methods and Functions (KEYWORD2) 13 | ########################################### 14 | init KEYWORD2 15 | begin KEYWORD2 16 | clear KEYWORD2 17 | home KEYWORD2 18 | noDisplay KEYWORD2 19 | display KEYWORD2 20 | noBlink KEYWORD2 21 | blink KEYWORD2 22 | noCursor KEYWORD2 23 | cursor KEYWORD2 24 | scrollDisplayLeft KEYWORD2 25 | scrollDisplayRight KEYWORD2 26 | leftToRight KEYWORD2 27 | rightToLeft KEYWORD2 28 | shiftIncrement KEYWORD2 29 | shiftDecrement KEYWORD2 30 | noBacklight KEYWORD2 31 | backlight KEYWORD2 32 | autoscroll KEYWORD2 33 | noAutoscroll KEYWORD2 34 | createChar KEYWORD2 35 | setCursor KEYWORD2 36 | print KEYWORD2 37 | blink_on KEYWORD2 38 | blink_off KEYWORD2 39 | cursor_on KEYWORD2 40 | cursor_off KEYWORD2 41 | setBacklight KEYWORD2 42 | load_custom_character KEYWORD2 43 | printstr KEYWORD2 44 | ########################################### 45 | # Constants (LITERAL1) 46 | ########################################### 47 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_I2C/library.properties: -------------------------------------------------------------------------------- 1 | name=LiquidCrystal_I2C 2 | version=2017-05-09-e3701fb 3 | author=DFRobot, Frank de Brabander, Michael Mayer 4 | maintainer=Michael Mayer 5 | sentence=Allows communication with alphanumerical liquid crystal displays (LCDs) connected via I2C. 6 | paragraph=This library allows an STM8 board to control LiquidCrystal displays (LCDs) using a I2C I/O expander board based on the PCF8574. It supports displays based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. 7 | category=Display 8 | url=https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library 9 | architectures=stm8 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/examples/BlinkingCursor/BlinkingCursor.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Demonstrates the use of lcd_Blink() and lcd_noBlink() 3 | * 4 | * modified for use with SDuino 5 | * 30.10.2018 by Michael Mayer 6 | */ 7 | #include 8 | #include 9 | 10 | // LCD controller settings 11 | #define LCD_ADDR 0x3B // I2C address: 0x3A or 0x3B, dep. on pin SA0 state 12 | #define LCD_RST PE3 // reset pin (active high) 13 | #define LCD_CHARSET 'R' // character set (A, D, F, I, R or S) 14 | 15 | // Set LCD address and reset pin 16 | LiquidCrystal_pcf2119(lcd, LCD_ADDR, LCD_RST, LCD_CHARSET); 17 | 18 | void setup() 19 | { 20 | // initialize the LCD (16x2 display) 21 | lcd_begin(16,2); 22 | } 23 | 24 | 25 | void loop() 26 | { 27 | bool blinking = true; 28 | lcd_cursor(); 29 | 30 | while (1) { 31 | if (blinking) { 32 | lcd_clear(); 33 | lcd_print_s("Cursor static "); 34 | lcd_noBlink(); 35 | blinking = false; 36 | } else { 37 | lcd_clear(); 38 | lcd_print_s("Cursor blink "); 39 | lcd_blink(); 40 | blinking = true; 41 | } 42 | delay(2500); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/examples/BlinkingCursor/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = mb208 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/examples/CustomChars/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = mb208 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/examples/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // LCD controller settings 5 | #define LCD_ADDR 0x3B // I2C address: 0x3A or 0x3B, dep. on pin SA0 state 6 | #define LCD_RST PE3 // reset pin (active high) 7 | #define LCD_CHARSET 'R' // character set (A, D, F, I, R or S) 8 | 9 | // Set LCD address and reset pin 10 | LiquidCrystal_pcf2119(lcd, LCD_ADDR, LCD_RST, LCD_CHARSET); 11 | 12 | void setup() 13 | { 14 | // initialize the LCD (16x2 display) 15 | lcd_begin(16,2); 16 | 17 | // Print a message. 18 | lcd_print_s("Hello, world!"); 19 | } 20 | 21 | void loop() 22 | { 23 | // Do nothing here... 24 | } 25 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/examples/HelloWorld/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = mb208 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/examples/SerialDisplay/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = mb208 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/examples/SerialDisplay/SerialDisplay.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Displays text sent over the serial port (e.g. from the Serial Monitor) on 3 | * an attached LCD. 4 | * 5 | * modified for use with SDuino 6 | * 30.10.2018 by Michael Mayer 7 | */ 8 | #include 9 | #include 10 | #include 11 | 12 | // LCD controller settings 13 | #define LCD_ADDR 0x3B // I2C address: 0x3A or 0x3B, dep. on pin SA0 state 14 | #define LCD_RST PE3 // reset pin (active high) 15 | #define LCD_CHARSET 'R' // character set (A, D, F, I, R or S) 16 | 17 | // Set LCD address and reset pin 18 | LiquidCrystal_pcf2119(lcd, LCD_ADDR, LCD_RST, LCD_CHARSET); 19 | 20 | void setup() 21 | { 22 | // initialize the LCD (16x2 display) 23 | lcd_begin(16,2); 24 | 25 | // Initialize the serial port at a speed of 9600 baud 26 | Serial_begin(9600); 27 | } 28 | 29 | void loop() 30 | { 31 | // If characters arrived over the serial port... 32 | if (Serial_available()) { 33 | // Wait a bit for the entire message to arrive 34 | delay(100); 35 | // Clear the screen 36 | lcd_clear(); 37 | 38 | // Write all ASCII characters received with the serial port to the LCD. 39 | while (Serial_available() > 0) { 40 | char c = Serial_read(); 41 | if (isalnum(c)) 42 | lcd_write(c); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/keywords.txt: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Syntax Coloring Map For LiquidCrystal_pcf2119 3 | ########################################### 4 | 5 | ########################################### 6 | # Datatypes (KEYWORD1) 7 | ########################################### 8 | 9 | LiquidCrystal_pcf2119 KEYWORD1 10 | 11 | ########################################### 12 | # Methods and Functions (KEYWORD2) 13 | ########################################### 14 | lcd_init KEYWORD2 15 | lcd_begin KEYWORD2 16 | lcd_clear KEYWORD2 17 | lcd_home KEYWORD2 18 | lcd_noDisplay KEYWORD2 19 | lcd_display KEYWORD2 20 | lcd_noBlink KEYWORD2 21 | lcd_blink KEYWORD2 22 | lcd_noCursor KEYWORD2 23 | lcd_cursor KEYWORD2 24 | lcd_scrollDisplayLeft KEYWORD2 25 | lcd_scrollDisplayRight KEYWORD2 26 | lcd_leftToRight KEYWORD2 27 | lcd_rightToLeft KEYWORD2 28 | lcd_autoscroll KEYWORD2 29 | lcd_noAutoscroll KEYWORD2 30 | lcd_createChar KEYWORD2 31 | lcd_setCursor KEYWORD2 32 | lcd_write KEYWORD2 33 | lcd_data KEYWORD2 34 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/library.properties: -------------------------------------------------------------------------------- 1 | name=LiquidCrystal_pcf2119 2 | version=0.1 3 | author=DFRobot, Frank de Brabander, Michael Mayer 4 | maintainer=Michael Mayer 5 | sentence=Allows communication with textmode LCDs based on the PCF2119 controller and connected via I2C. 6 | paragraph=This library allows an STM8 board to control LiquidCrystal displays (LCDs) based on the PCF2119 controller and connected via I2C. This library does not work the more widespread HD44780 based displays with a parallel interface and connected to the I2C bus using a backpacked I/O expander board. For that kind of display please use the LiquidCrystal_I2C library. 7 | category=Display 8 | url= 9 | architectures=stm8 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/LiquidCrystal_pcf2119/test_library.txt: -------------------------------------------------------------------------------- 1 | ok: 2 | LiquidCrystal_pcf2119 3 | lcd_begin 4 | lcd_clear 5 | lcd_home 6 | lcd_noDisplay 7 | lcd_display 8 | lcd_noBlink 9 | lcd_blink 10 | lcd_noCursor 11 | lcd_cursor 12 | lcd_leftToRight 13 | lcd_rightToLeft 14 | lcd_noAutoscroll 15 | lcd_createChar 16 | lcd_setCursor 17 | lcd_write(c) 18 | lcd_data(c) 19 | lcd_print_s 20 | lcd_print_i 21 | lcd_print_ub 22 | other print_*...? 23 | 24 | 25 | fail: 26 | lcd_scrollDisplayLeft arrow at (16,2) due to wrong charset 27 | lcd_scrollDisplayRight arrow at (1,1) due to wrong charset 28 | lcd_autoscroll arrow at (16,2) due to wrong charset. Likely fixed by lcd_scrollDisplayLeft() 29 | 30 | 31 | only declared (->compile error) -> deleted 32 | lcd_printLeft 33 | lcd_printRight 34 | lcd_shiftIncrement 35 | lcd_shiftDecrement 36 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Mini_SSD1306/examples/oled-mini/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Mini_SSD1306/examples/oled-mini/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 -DARDUINO=180 \ 14 | -I. -I$(SDUINO) -I$(SDUINO)/libraries/I2C -I$(LIBBASE)/inc \ 15 | -I/usr/share/sdcc/include/ 16 | # -DSUPPORT_ALTERNATE_MAPPINGS 17 | 18 | LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103 19 | 20 | OBJECTS=$(BASENAME).rel ssd1306.rel 21 | #SDLIBS=I2C 22 | SDOBJECTS=main.rel wiring.rel wiring_digital.rel 23 | SDLIBOBJECTS=I2C.rel 24 | 25 | .PHONY: all clean flash 26 | 27 | #all: $(OBJECTS) 28 | 29 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) $(SDLIBOBJECTS) 30 | #test.rel wiring_digital.rel 31 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 32 | 33 | $(OBJECTS) : %.rel : %.c 34 | $(CC) -c $(CFLAGS) $^ -o $@ 35 | 36 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 37 | $(CC) -c $(CFLAGS) $^ -o $@ 38 | 39 | $(SDLIBOBJECTS) : %.rel : $(SDUINO)/libraries/I2C/%.c 40 | $(CC) -c $(CFLAGS) $^ -o $@ 41 | 42 | flash: $(EXECUTABLE) 43 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 44 | 45 | readopt: 46 | stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin 47 | 48 | 49 | clean: 50 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 51 | *.cdb *.adb *~ *.bak 52 | rm -f $(EXECUTABLE) 53 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/PCD8544/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Carlos Rodrigues 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/PCD8544/examples/HelloWorld/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/PCD8544/examples/Thermometer/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/PCD8544/library.properties: -------------------------------------------------------------------------------- 1 | name=PCD8544 2 | version=1.4.3 3 | author=Carlos Rodrigues 4 | maintainer=Carlos Rodrigues 5 | sentence=Philips PCD8544 or compatible LCD library. 6 | paragraph=PCD8544 supports monochrome LCDs most commonly found on old Nokia phones. This is a minimal library intended for low memory usage. 7 | category=Display 8 | url=https://github.com/carlosefr/pcd8544 9 | architectures=* 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Servo/README.adoc: -------------------------------------------------------------------------------- 1 | = Servo Library for Arduino = 2 | 3 | This library allows an Arduino board to control RC (hobby) servo motors. 4 | 5 | For more information about this library please visit us at 6 | http://www.arduino.cc/en/Reference/Servo 7 | 8 | == License == 9 | 10 | Copyright (c) 2013 Arduino LLC. All right reserved. 11 | Copyright (c) 2009 Michael Margolis. All right reserved. 12 | 13 | This library is free software; you can redistribute it and/or 14 | modify it under the terms of the GNU Lesser General Public 15 | License as published by the Free Software Foundation; either 16 | version 2.1 of the License, or (at your option) any later version. 17 | 18 | This library is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public 24 | License along with this library; if not, write to the Free Software 25 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Servo/examples/Knob/Knob.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Controlling a servo position using a potentiometer (variable resistor) 3 | by Michal Rinott 4 | 5 | modified on 8 Nov 2013 6 | by Scott Fitzgerald 7 | http://www.arduino.cc/en/Tutorial/Knob 8 | modified to C syntax on 30 Jan 2017 for use with the sdunio environment 9 | by Michael Mayer 10 | */ 11 | 12 | #include 13 | 14 | Servo(myservo); // create servo "object" to control a servo 15 | 16 | int potpin = 0; // analog pin used to connect the potentiometer 17 | int val; // variable to read the value from the analog pin 18 | 19 | void setup() { 20 | myservo_attach(9); // attaches the servo on pin 9 to the servo object 21 | } 22 | 23 | 24 | void loop() { 25 | 26 | val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) 27 | val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180) 28 | myservo_write(val); // sets the servo position according to the scaled value 29 | delay(15); // waits for the servo to get there 30 | } 31 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Servo/examples/Knob/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Servo/examples/Sweep/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Servo/examples/Sweep/Sweep.ino: -------------------------------------------------------------------------------- 1 | /* Sweep 2 | by BARRAGAN 3 | This example code is in the public domain. 4 | 5 | modified 8 Nov 2013 6 | by Scott Fitzgerald 7 | http://www.arduino.cc/en/Tutorial/Sweep 8 | modified to C syntax on 30 Jan 2017 for use with the sdunio environment 9 | by Michael Mayer 10 | */ 11 | 12 | #include 13 | 14 | Servo(myservo); // create servo "object" to control a servo 15 | // twelve servo objects can be created on most boards 16 | 17 | int pos = 0; // variable to store the servo position 18 | 19 | void setup() { 20 | myservo_attach(9); // attaches the servo on pin 9 to the servo object 21 | } 22 | 23 | void loop() { 24 | for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees 25 | // in steps of 1 degree 26 | myservo_write(pos); // tell servo to go to position in variable 'pos' 27 | delay(15); // waits 15ms for the servo to reach the position 28 | } 29 | for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees 30 | myservo_write(pos); // tell servo to go to position in variable 'pos' 31 | delay(15); // waits 15ms for the servo to reach the position 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Servo/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map Servo 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Servo KEYWORD1 Servo 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | attach KEYWORD2 15 | detach KEYWORD2 16 | write KEYWORD2 17 | read KEYWORD2 18 | attached KEYWORD2 19 | writeMicroseconds KEYWORD2 20 | readMicroseconds KEYWORD2 21 | 22 | ####################################### 23 | # Constants (LITERAL1) 24 | ####################################### 25 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Servo/library.properties: -------------------------------------------------------------------------------- 1 | name=Servo 2 | version=1.1.2 3 | author=Michael Margolis, Arduino 4 | maintainer=Arduino 5 | sentence=Allows Arduino/Genuino boards to control a variety of servo motors. 6 | paragraph=This library can control a great number of servos.
It makes careful use of timers: the library can control 12 servos using only 1 timer.
On the Arduino Due you can control up to 60 servos.
7 | category=Device Control 8 | url=http://www.arduino.cc/en/Reference/Servo 9 | architectures=stm8 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/README.adoc: -------------------------------------------------------------------------------- 1 | = Stepper Library for Arduino = 2 | 3 | This library allows you to control unipolar or bipolar stepper motors. To use it you will need a stepper motor, and the appropriate hardware to control it. 4 | 5 | For more information about this library please visit us at 6 | http://www.arduino.cc/en/Reference/Stepper 7 | 8 | == License == 9 | 10 | Copyright (c) Arduino LLC. All right reserved. 11 | Copyright (c) Sebastian Gassner. All right reserved. 12 | Copyright (c) Noah Shibley. All right reserved. 13 | 14 | This library is free software; you can redistribute it and/or 15 | modify it under the terms of the GNU Lesser General Public 16 | License as published by the Free Software Foundation; either 17 | version 2.1 of the License, or (at your option) any later version. 18 | 19 | This library is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | Lesser General Public License for more details. 23 | 24 | You should have received a copy of the GNU Lesser General Public 25 | License along with this library; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/MotorKnob/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/MotorKnob/MotorKnob.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * MotorKnob 3 | * 4 | * A stepper motor follows the turns of a potentiometer 5 | * (or other sensor) on analog input 0. 6 | * 7 | * http://www.arduino.cc/en/Reference/Stepper 8 | * This example code is in the public domain. 9 | */ 10 | 11 | #include 12 | 13 | // change this to the number of steps on your motor 14 | #define STEPS 200 15 | 16 | // create an instance of the stepper class, specifying 17 | // the number of steps of the motor and the pins it's 18 | // attached to 19 | Stepper(stepper,STEPS, 8, 9, 10, 11); 20 | 21 | // the previous reading from the analog input 22 | int previous = 0; 23 | 24 | void setup() { 25 | // set the speed of the motor to 30 RPMs 26 | stepper_setSpeed(30); 27 | } 28 | 29 | void loop() { 30 | // get the sensor value 31 | int val = analogRead(0); 32 | 33 | // move a number of steps equal to the change in the 34 | // sensor reading 35 | stepper_step(val - previous); 36 | 37 | // remember the previous value of the sensor 38 | previous = val; 39 | } 40 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/stepper_oneRevolution/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | #CFLAGS = -DNO_5PHASE 3 | 4 | include ../../../../sduino.mk 5 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/stepper_oneRevolution/stepper_oneRevolution.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Stepper Motor Control - one revolution 4 | 5 | This program drives a unipolar or bipolar stepper motor. 6 | The motor is attached to digital pins 8 - 11 of the Arduino. 7 | 8 | The motor should revolve one revolution in one direction, then 9 | one revolution in the other direction. 10 | 11 | 12 | Created 11 Mar. 2007 13 | Modified 30 Nov. 2009 14 | by Tom Igoe 15 | Modified 28 Jan. 2017 to C syntax for use with sduino environment 16 | by Michael Mayer 17 | 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | // change this to fit the number of steps per revolution for your motor 24 | #define stepsPerRevolution 200 25 | 26 | // initialize the stepper library on pins 8 through 11: 27 | Stepper (myStepper,stepsPerRevolution, 8, 9, 10, 11); 28 | 29 | void setup() { 30 | // set the speed at 60 rpm: 31 | myStepper_setSpeed(60); 32 | // initialize the serial port: 33 | Serial_begin(9600); 34 | } 35 | 36 | void loop() { 37 | // step one revolution in one direction: 38 | Serial_println_s("clockwise"); 39 | myStepper_step(stepsPerRevolution); 40 | delay(500); 41 | 42 | // step one revolution in the other direction: 43 | Serial_println_s("counterclockwise"); 44 | myStepper_step(-stepsPerRevolution); 45 | delay(500); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/stepper_oneStepAtATime/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/stepper_oneStepAtATime/stepper_oneStepAtATime.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Stepper Motor Control - one step at a time 4 | 5 | This program drives a unipolar or bipolar stepper motor. 6 | The motor is attached to digital pins 8 - 11 of the Arduino. 7 | 8 | The motor will step one step at a time, very slowly. You can use this to 9 | test that you've got the four wires of your stepper wired to the correct 10 | pins. If wired correctly, all steps should be in the same direction. 11 | 12 | Use this also to count the number of steps per revolution of your motor, 13 | if you don't know it. Then plug that number into the oneRevolution 14 | example to see if you got it right. 15 | 16 | Created 30 Nov. 2009 17 | by Tom Igoe 18 | Modified 28 Jan. 2017 to C syntax for use with sduino environment 19 | by Michael Mayer 20 | 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #define stepsPerRevolution 200 // change this to fit the number of steps per revolution 27 | // for your motor 28 | 29 | // initialize the stepper library on pins 8 through 11: 30 | Stepper (myStepper,stepsPerRevolution, 8, 9, 10, 11); 31 | 32 | int stepCount = 0; // number of steps the motor has taken 33 | 34 | void setup() { 35 | // initialize the serial port: 36 | Serial_begin(9600); 37 | } 38 | 39 | void loop() { 40 | // step one step: 41 | myStepper_step(1); 42 | Serial_print_s("steps:"); 43 | Serial_println_u(stepCount); 44 | stepCount++; 45 | delay(500); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/stepper_speedControl/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/examples/stepper_speedControl/stepper_speedControl.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Stepper Motor Control - speed control 4 | 5 | This program drives a unipolar or bipolar stepper motor. 6 | The motor is attached to digital pins 8 - 11 of the Arduino. 7 | A potentiometer is connected to analog input 0. 8 | 9 | The motor will rotate in a clockwise direction. The higher the potentiometer value, 10 | the faster the motor speed. Because setSpeed() sets the delay between steps, 11 | you may notice the motor is less responsive to changes in the sensor value at 12 | low speeds. 13 | 14 | Created 30 Nov. 2009 15 | Modified 28 Oct 2010 16 | by Tom Igoe 17 | Modified 28 Jan. 2017 to C syntax for use with sduino environment 18 | by Michael Mayer 19 | 20 | */ 21 | 22 | #include 23 | 24 | #define stepsPerRevolution 200 // change this to fit the number of steps per revolution 25 | // for your motor 26 | 27 | 28 | // initialize the stepper library on pins 8 through 11: 29 | Stepper (myStepper,stepsPerRevolution, 8, 9, 10, 11); 30 | 31 | int stepCount = 0; // number of steps the motor has taken 32 | 33 | void setup() { 34 | // nothing to do inside the setup 35 | } 36 | 37 | void loop() { 38 | // read the sensor value: 39 | int sensorReading = analogRead(A0); 40 | // map it to a range from 0 to 100: 41 | int motorSpeed = map(sensorReading, 0, 1023, 0, 100); 42 | // set the motor speed: 43 | if (motorSpeed > 0) { 44 | myStepper_setSpeed(motorSpeed); 45 | // step 1/100 of a revolution: 46 | myStepper_step(stepsPerRevolution / 100); 47 | } 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Test 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Stepper KEYWORD1 Stepper 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | step KEYWORD2 16 | setSpeed KEYWORD2 17 | version KEYWORD2 18 | 19 | ###################################### 20 | # Instances (KEYWORD2) 21 | ####################################### 22 | direction KEYWORD2 23 | speed KEYWORD2 24 | 25 | 26 | ####################################### 27 | # Constants (LITERAL1) 28 | ####################################### 29 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Stepper/library.properties: -------------------------------------------------------------------------------- 1 | name=Stepper 2 | version=1.1.3 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Allows Arduino boards to control a variety of stepper motors. 6 | paragraph=This library allows you to control unipolar or bipolar stepper motors. To use it you will need a stepper motor, and the appropriate hardware to control it. 7 | category=Device Control 8 | url=http://www.arduino.cc/en/Reference/Stepper 9 | architectures=* 10 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/SFRRanger_reader/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/digital_potentiometer/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino: -------------------------------------------------------------------------------- 1 | // I2C Digital Potentiometer 2 | // by Nicholas Zambetti 3 | // and Shawn Bonkowski 4 | 5 | // Demonstrates use of the Wire library 6 | // Controls AD5171 digital potentiometer via I2C/TWI 7 | 8 | // Adapted to plain C for SDunio by M. Mayer 27 November 2018 9 | // Created 31 March 2006 10 | 11 | // This example code is in the public domain. 12 | 13 | 14 | #include 15 | 16 | void setup() { 17 | Wire_begin(); // join i2c bus (address optional for master) 18 | } 19 | 20 | byte val = 0; 21 | 22 | void loop() { 23 | Wire_beginTransmission(44); // transmit to device #44 (0x2c) 24 | // device address is specified in datasheet 25 | Wire_write(0x00); // sends instruction byte 26 | Wire_write(val); // sends potentiometer value byte 27 | Wire_endTransmission(); // stop transmitting 28 | 29 | val++; // increment value 30 | if (val == 64) { // if reached 64th position (max) 31 | val = 0; // start over from lowest value 32 | } 33 | delay(500); 34 | } 35 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/i2c_scanner/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/master_reader/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/master_reader/master_reader.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Reader 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Reads data from an I2C/TWI slave device 6 | // Refer to the "Wire Slave Sender" example for use with this 7 | 8 | // Adapted to plain C for SDunio by M. Mayer 29 November 2018 9 | // Created 29 March 2006 10 | 11 | // This example code is in the public domain. 12 | 13 | 14 | #include 15 | 16 | void setup() { 17 | Wire_begin(); // join i2c bus (address optional for master) 18 | Serial_begin(9600); // start serial for output 19 | } 20 | 21 | void loop() { 22 | Wire_requestFrom(8, 6); // request 6 bytes from slave device #8 23 | 24 | while (Wire_available()) { // slave may send less than requested 25 | char c = Wire_read(); // receive a byte as character 26 | Serial_print_c(c); // print the character 27 | } 28 | 29 | delay(500); 30 | } 31 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/master_writer/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/master_writer/master_writer.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Writer 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Writes data to an I2C/TWI slave device 6 | // Refer to the "Wire Slave Receiver" example for use with this 7 | 8 | // Adapted to plain C for SDunio by M. Mayer 27 November 2018 9 | // Created 29 March 2006 10 | 11 | // This example code is in the public domain. 12 | 13 | 14 | #include 15 | 16 | void setup() { 17 | Wire_begin(); // join i2c bus (address optional for master) 18 | } 19 | 20 | byte x = 0; 21 | 22 | void loop() { 23 | Wire_beginTransmission(8); // transmit to device #8 24 | Wire_write_s("x is "); // sends five bytes 25 | Wire_write(x); // sends one byte 26 | Wire_endTransmission(); // stop transmitting 27 | 28 | x++; 29 | delay(500); 30 | } 31 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/pcf8574/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../../../sduino.mk 4 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/slave_receiver/slave_receiver.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Receiver 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Receives data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Writer" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(8); // join i2c bus with address #8 17 | Wire.onReceive(receiveEvent); // register event 18 | Serial.begin(9600); // start serial for output 19 | } 20 | 21 | void loop() { 22 | delay(100); 23 | } 24 | 25 | // function that executes whenever data is received from master 26 | // this function is registered as an event, see setup() 27 | void receiveEvent(int howMany) { 28 | while (1 < Wire.available()) { // loop through all but the last 29 | char c = Wire.read(); // receive byte as a character 30 | Serial.print(c); // print the character 31 | } 32 | int x = Wire.read(); // receive byte as an integer 33 | Serial.println(x); // print the integer 34 | } 35 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/examples/slave_sender/slave_sender.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Sender 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Sends data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Reader" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(8); // join i2c bus with address #8 17 | Wire.onRequest(requestEvent); // register event 18 | } 19 | 20 | void loop() { 21 | delay(100); 22 | } 23 | 24 | // function that executes whenever data is requested by master 25 | // this function is registered as an event, see setup() 26 | void requestEvent() { 27 | Wire.write("hello "); // respond with message of 6 bytes 28 | // as expected by master 29 | } 30 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Wire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | begin KEYWORD2 14 | setClock KEYWORD2 15 | beginTransmission KEYWORD2 16 | endTransmission KEYWORD2 17 | requestFrom KEYWORD2 18 | onReceive KEYWORD2 19 | onRequest KEYWORD2 20 | 21 | ####################################### 22 | # Instances (KEYWORD2) 23 | ####################################### 24 | 25 | Wire KEYWORD2 26 | 27 | ####################################### 28 | # Constants (LITERAL1) 29 | ####################################### 30 | 31 | -------------------------------------------------------------------------------- /sduino/stm8/libraries/Wire/library.properties: -------------------------------------------------------------------------------- 1 | name=Wire 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=This library allows you to communicate with I2C and Two Wire Interface devices. 6 | paragraph=It allows the communication with I2C devices like temperature sensors, realtime clocks and many others using SDA (Data Line) and SCL (Clock Line). 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/Wire 9 | architectures=avr 10 | 11 | -------------------------------------------------------------------------------- /sduino/stm8/programmers.txt: -------------------------------------------------------------------------------- 1 | stlink21.name=ST-Link/V2.1 2 | stlink21.communication=usb 3 | stlink21.protocol=stlinkv21 4 | stlink21.program.tool=stm8flash 5 | stlink21.program.extra_params= 6 | 7 | stlink2.name=ST-Link/V2 8 | stlink2.communication=usb 9 | stlink2.protocol=stlinkv2 10 | stlink2.program.tool=stm8flash 11 | stlink2.program.extra_params= 12 | 13 | stlink1.name=ST-Link/V1 14 | stlink1.communication=usb 15 | stlink1.protocol=stlinkv1 16 | stlink1.program.tool=stm8flash 17 | stlink1.program.extra_params= 18 | 19 | serialboot.name=Serial STM8 bootloader 20 | serialboot.communication=serial 21 | serialboot.protocol=stlinkv1 22 | serialboot.program.tool=stm8gal 23 | serialboot.program.extra_params= 24 | -------------------------------------------------------------------------------- /sduino/tools/armhf/stm8gal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/armhf/stm8gal -------------------------------------------------------------------------------- /sduino/tools/linux32/stm8flash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/linux32/stm8flash -------------------------------------------------------------------------------- /sduino/tools/linux32/stm8gal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/linux32/stm8gal -------------------------------------------------------------------------------- /sduino/tools/linux64/stm8flash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/linux64/stm8flash -------------------------------------------------------------------------------- /sduino/tools/linux64/stm8gal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/linux64/stm8gal -------------------------------------------------------------------------------- /sduino/tools/macosx/stm8flash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/macosx/stm8flash -------------------------------------------------------------------------------- /sduino/tools/macosx/stm8gal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/macosx/stm8gal -------------------------------------------------------------------------------- /sduino/tools/win/busybox.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/win/busybox.exe -------------------------------------------------------------------------------- /sduino/tools/win/libusb-1.0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/win/libusb-1.0.dll -------------------------------------------------------------------------------- /sduino/tools/win/stm8flash.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/win/stm8flash.exe -------------------------------------------------------------------------------- /sduino/tools/win/stm8gal.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/tools/win/stm8gal.exe -------------------------------------------------------------------------------- /test/adc1/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | CFLAGS= --debug -DSUPPORT_ALTERNATE_MAPPINGS 4 | 5 | include ../../sduino/stm8/sduino.mk 6 | -------------------------------------------------------------------------------- /test/adc1/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 -DSUPPORT_ALTERNATE_MAPPINGS \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/ 15 | 16 | LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103 17 | 18 | OBJECTS=$(BASENAME).rel 19 | SDOBJECTS=main.rel wiring.rel wiring_digital.rel wiring_analog.rel \ 20 | HardwareSerial.rel Print.rel 21 | 22 | .PHONY: all clean flash 23 | 24 | #all: $(OBJECTS) 25 | 26 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 27 | #test.rel wiring_digital.rel 28 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 29 | 30 | $(OBJECTS) : %.rel : %.c 31 | $(CC) -c $(CFLAGS) $^ -o $@ 32 | 33 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 34 | $(CC) -c $(CFLAGS) $^ -o $@ 35 | 36 | flash: $(EXECUTABLE) 37 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 38 | 39 | readopt: 40 | stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin 41 | 42 | 43 | clean: 44 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 45 | *.cdb *.adb *~ *.bak 46 | rm -f $(EXECUTABLE) 47 | -------------------------------------------------------------------------------- /test/adc1/adc1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test adc1, read all five channels 3 | * 4 | * But skip channel 4, as it is used as TX. analogRead would mess up the 5 | * send data while the ADC is active. 6 | */ 7 | 8 | #include "Arduino.h" 9 | #include "Serial.h" 10 | 11 | 12 | void setup(void) 13 | { 14 | Serial_begin(115200); 15 | Serial_println_s("ADC test"); 16 | 17 | // configure analog pins for input 18 | pinMode(A0, INPUT); 19 | pinMode(A1, INPUT); 20 | pinMode(A2, INPUT); 21 | pinMode(A3, INPUT); // this pin is used as TX 22 | pinMode(A4, INPUT); // this pin is used as RX 23 | } 24 | 25 | 26 | void loop (void) 27 | { 28 | uint8_t i; 29 | uint16_t val; 30 | 31 | for (i=0; i irgendwie müsste sich die Standardbelegung einstellbar oder ganz abstellbar 17 | machen. 18 | 19 | dependencies: 20 | Compilieren und Dependencies gleichzeitig geht mit: 21 | `sdcc -Wp"-MMD abc" .....` (mit filename für dep.) 22 | 23 | erwartet wird: 24 | `sdcc -MMD .....` (ohne filename für dep.) 25 | dieser Aufruf erzeugt aber nur die dep. in der rel-Datei und kein Object file 26 | 27 | Der Assembler erzeugt immer .rel-Files, es werden aber .o-Files erwartet. 28 | 29 | 30 | 31 | ### general suggestions for Arduino.mk: 32 | 33 | - rename the programmer specific variables from AVRDUDE_xxxx to a more 34 | generic PROGRAMMER_xxxx 35 | - allow predefined AVRDUDE_xxxx definitions from the Makefile to override 36 | the PROGRAMMER_xxxx definitions 37 | 38 | -------------------------------------------------------------------------------- /test/libmake/stat.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gawk -f 2 | 3 | # text data bss dec hex filename 4 | # 0 4673 0 4673 1241 build-stm8sblue/libmake.ihx 5 | 6 | 7 | / [ls]_/ { 8 | v=strtonum("0x"$1); 9 | type=substr($2,1,1); 10 | name=substr($2,3); 11 | arr[name][type]=v; 12 | # print v,type,name,$0 13 | } 14 | 15 | END { 16 | bss = arr["DATA"]["l"]+arr["INITIALIZED"]["l"]; 17 | rom = arr["CODE"]["l"]+arr["INITIALIZER"]["l"]; 18 | 19 | for (n in arr) 20 | print arr[n]["l"] "\t" n; 21 | # print n, arr[n]["s"],arr[n]["l"]; 22 | print "memory usage statics" 23 | print "--------------------" 24 | print "RAM:\t\t" arr["DATA"]["l"]+arr["INITIALIZED"]["l"]; 25 | print "Flash:\t\t" arr["CODE"]["l"]+arr["INITIALIZER"]["l"]; 26 | for (n in arr) printf("%s\t",n); 27 | for (n in arr) print arr[n]["l"] "\t"; 28 | 29 | print " text\t data\t bss\t dec\t hex\tfilename"; 30 | printf ("%7i\t%7i\t%7i\t%7i\t%7x\t%s\n",0,rom,bss,rom,rom,FILENAME); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /test/pinmode/pinmode-c.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test spi functions 3 | */ 4 | 5 | #include "Arduino.h" 6 | 7 | void pinMode_c(uint8_t pin, uint8_t mode) 8 | { 9 | uint8_t bit = digitalPinToBitMask(pin); 10 | uint8_t port = digitalPinToPort(pin); 11 | volatile GPIO_TypeDef *gpio; 12 | 13 | if (port == NOT_A_PORT) return; 14 | 15 | gpio = (GPIO_TypeDef *) portOutputRegister(port); 16 | 17 | if (mode == INPUT) { 18 | BEGIN_CRITICAL 19 | gpio->CR2 &= ~bit; // first: deactivate interrupt 20 | gpio->CR1 &= ~bit; // release top side 21 | gpio->DDR &= ~bit; // now set direction 22 | END_CRITICAL 23 | } else if (mode == INPUT_PULLUP) { 24 | BEGIN_CRITICAL 25 | gpio->CR2 &= ~bit; // first: deactivate interrupt 26 | gpio->DDR &= ~bit; // set direction before 27 | gpio->CR1 |= bit; // activating the pull up 28 | END_CRITICAL 29 | } else if (mode == OUTPUT_FAST) {// output push-pull, fast 30 | BEGIN_CRITICAL 31 | gpio->CR1 |= bit; 32 | gpio->DDR |= bit; // direction before setting CR2 to 33 | gpio->CR2 |= bit; // avoid accidental interrupt 34 | END_CRITICAL 35 | } else if (mode == OUTPUT_OD_FAST) { // output open drain, fast 36 | BEGIN_CRITICAL 37 | gpio->CR1 &= ~bit; 38 | gpio->DDR |= bit; // direction before setting CR2 to 39 | gpio->CR2 |= bit; // avoid accidental interrupt 40 | END_CRITICAL 41 | } else if (mode == OUTPUT_OD) { // output open drain, slow 42 | BEGIN_CRITICAL 43 | gpio->CR1 &= ~bit; 44 | gpio->CR2 &= ~bit; 45 | gpio->DDR |= bit; 46 | END_CRITICAL 47 | } else { // output push-pull, slow 48 | BEGIN_CRITICAL 49 | gpio->CR1 |= bit; 50 | gpio->CR2 &= ~bit; 51 | gpio->DDR |= bit; 52 | END_CRITICAL 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test/pinmode/sim: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sstm8 -t S103 pinmode.ihx << EOF 4 | fill ram_chip 0 1023 0 5 | fill io_chip 0 44 0 6 | s 10000 7 | du io_chip 0 4 8 | du io_chip 5 9 9 | du io_chip 10 14 10 | du io_chip 15 19 11 | du ram_chip 1 6 12 | du ram_chip 0x0100 13 | quit 14 | EOF 15 | -------------------------------------------------------------------------------- /test/pinmode/test_generic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test the use of the _Generic preprocessor directive 3 | */ 4 | 5 | void func_uint8(const unsigned char); 6 | void func_int8(const unsigned char); 7 | void func_uint16(const unsigned char); 8 | void func_int16(const unsigned char); 9 | void func_var(const unsigned char); 10 | 11 | unsigned char mode; 12 | 13 | void test_generic(void) 14 | { 15 | _Generic(mode, 16 | // const unsigned char: func_uint8(mode), 17 | // const char: func_int8(mode), 18 | const unsigned int: func_uint16(mode), 19 | const int: func_int16(mode), 20 | default: func_var(mode) 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /test/print/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../sduino/stm8/sduino.mk 4 | -------------------------------------------------------------------------------- /test/print/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../sduino/stm8/STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=2000000L -DSTM8S103 \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I$(SDCCBASE)/share/sdcc/include/ 15 | 16 | LDFLAGS=-L$(LIBBASE)/src -L$(SDCCBASE)/share/sdcc/lib/stm8 -lstm8s 17 | 18 | OBJECTS=$(BASENAME).rel 19 | SDOBJECTS=main.rel wiring.rel \ 20 | HardwareSerial.rel Print.rel 21 | 22 | .PHONY: all clean flash 23 | 24 | #all: $(OBJECTS) 25 | 26 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 27 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 28 | 29 | $(OBJECTS) : %.rel : %.c 30 | $(CC) -c $(CFLAGS) $^ -o $@ 31 | 32 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 33 | $(CC) -c $(CFLAGS) $^ -o $@ 34 | 35 | flash: $(EXECUTABLE) 36 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 37 | 38 | 39 | clean: 40 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 41 | *.cdb *.adb *~ *.bak 42 | rm -f $(EXECUTABLE) 43 | -------------------------------------------------------------------------------- /test/print/print.c: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "Serial.h" 3 | 4 | void setup (void) 5 | { 6 | Serial_begin(115200); 7 | Serial_println_s("\nPrint test"); 8 | 9 | Serial_println_ib(1234,10); 10 | Serial_println_ib(1234,16); 11 | Serial_println_ib(1234,2); 12 | 13 | Serial_println_u(2345); 14 | Serial_println_u(-3); 15 | Serial_println_i(-3); 16 | 17 | Serial_println_fd(PI,10); 18 | Serial_println_fd(PI,11); 19 | Serial_println_fd(PI,12); 20 | Serial_println_fd(-PI,13); 21 | } 22 | 23 | void loop() 24 | { 25 | char c; 26 | 27 | if (Serial_available()) { 28 | c = Serial_read(); 29 | Serial_print_s("character read: 0x"); 30 | Serial_println_ub(c,HEX); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/pwm1/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../sduino/stm8/sduino.mk 4 | -------------------------------------------------------------------------------- /test/pwm1/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/ 15 | # -DSUPPORT_ALTERNATE_MAPPINGS 16 | 17 | LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103 18 | 19 | OBJECTS=$(BASENAME).rel 20 | SDOBJECTS=main.rel wiring.rel wiring_digital.rel wiring_analog.rel \ 21 | HardwareSerial.rel Print.rel 22 | 23 | .PHONY: all clean flash 24 | 25 | #all: $(OBJECTS) 26 | 27 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 28 | #test.rel wiring_digital.rel 29 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 30 | 31 | $(OBJECTS) : %.rel : %.c 32 | $(CC) -c $(CFLAGS) $^ -o $@ 33 | 34 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 35 | $(CC) -c $(CFLAGS) $^ -o $@ 36 | 37 | flash: $(EXECUTABLE) 38 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 39 | 40 | readopt: 41 | stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin 42 | 43 | 44 | clean: 45 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 46 | *.cdb *.adb *~ *.bak 47 | rm -f $(EXECUTABLE) 48 | -------------------------------------------------------------------------------- /test/serial/Makefile: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../sduino/stm8/STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino/stm8/cores/sduino 12 | PINS=../../sduino/stm8/variants/standard 13 | 14 | CFLAGS= --debug -mstm8 -DF_CPU=2000000L -DSTM8S103 \ 15 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I$(PINS) -I/usr/share/sdcc/include/ 16 | 17 | LDFLAGS=-L$(LIBBASE)/src -L$(SDCCBASE)/share/sdcc/lib/stm8 -lstm8s 18 | 19 | OBJECTS=$(BASENAME).rel HardwareSerial.rel 20 | #SDOBJECTS=HardwareSerial.rel 21 | 22 | .PHONY: all clean flash 23 | 24 | #all: $(OBJECTS) 25 | 26 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 27 | #test.rel wiring_digital.rel 28 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 29 | 30 | $(OBJECTS) : %.rel : %.c 31 | $(CC) -c $(CFLAGS) $^ -o $@ 32 | 33 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 34 | $(CC) -c $(CFLAGS) $^ -o $@ 35 | 36 | flash: $(EXECUTABLE) 37 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 38 | 39 | # Re-build HardwareSerial.c from the little parts in the core directory 40 | HardwareSerial.c: 41 | grep -hv '#include "HardwareSerial.c.h"' \ 42 | $(SDUINO)/HardwareSerial.c.h \ 43 | $(SDUINO)/HardwareSerial.c-*.c > $@ 44 | 45 | clean: 46 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 47 | *.cdb *.adb *~ *.bak 48 | rm -f $(EXECUTABLE) 49 | -------------------------------------------------------------------------------- /test/serial/NON-FUNCTIONAL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/test/serial/NON-FUNCTIONAL -------------------------------------------------------------------------------- /test/serial/serial.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test HardwareSerial.c using spl functions 3 | * no dependencies to wiring 4 | */ 5 | 6 | #include "stm8s.h" 7 | #include "HardwareSerial.h" 8 | 9 | void UART1_RX_IRQHandler(void) __interrupt(ITC_IRQ_UART1_RX); /* UART1 RX */ 10 | void UART1_TX_IRQHandler(void) __interrupt(ITC_IRQ_UART1_TX); /* UART1 TX */ 11 | 12 | 13 | 14 | void send_string(char *str) 15 | { 16 | char c; 17 | 18 | if (!str) return; 19 | 20 | while ( c=*str++ ) HardwareSerial_write(c); // assignment intented 21 | } 22 | 23 | 24 | void main (void) 25 | { 26 | uint32_t i; 27 | 28 | UART1_DeInit(); 29 | enableInterrupts(); 30 | 31 | HardwareSerial_begin(9600); 32 | 33 | while (1) { 34 | send_string("Hello World!\r\n"); 35 | for (i=15000; i; i--); 36 | while(HardwareSerial_available()) { 37 | HardwareSerial_write('.'); 38 | HardwareSerial_write(HardwareSerial_read()); 39 | }; 40 | for (i=15000; i; i--); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/serial2/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../sduino/stm8/sduino.mk 4 | -------------------------------------------------------------------------------- /test/serial2/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=2000000L -DSTM8S103 \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/ 15 | 16 | LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s 17 | 18 | OBJECTS=$(BASENAME).rel 19 | SDOBJECTS=main.rel wiring.rel HardwareSerial.rel 20 | 21 | .PHONY: all clean flash 22 | 23 | #all: $(OBJECTS) 24 | 25 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 26 | #test.rel wiring_digital.rel 27 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 28 | 29 | $(OBJECTS) : %.rel : %.c 30 | $(CC) -c $(CFLAGS) $^ -o $@ 31 | 32 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 33 | $(CC) -c $(CFLAGS) $^ -o $@ 34 | 35 | flash: $(EXECUTABLE) 36 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 37 | 38 | 39 | clean: 40 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 41 | *.cdb *.adb *~ *.bak 42 | rm -f $(EXECUTABLE) 43 | -------------------------------------------------------------------------------- /test/serial2/serial2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test HardwareSerial.c using sduino functions 3 | */ 4 | 5 | #include "Arduino.h" 6 | #include "HardwareSerial.h" 7 | 8 | 9 | 10 | void send_string(char *str) 11 | { 12 | char c; 13 | 14 | if (!str) return; 15 | 16 | while ( c=*str++ ) HardwareSerial_write(c); // assignment intented 17 | } 18 | 19 | 20 | void setup(void) 21 | { 22 | HardwareSerial_begin(9600); 23 | } 24 | 25 | 26 | void loop (void) 27 | { 28 | uint32_t i; 29 | 30 | send_string("Hello World!\r\n"); 31 | 32 | for (i=60000; i; i--); 33 | while(HardwareSerial_available()) { 34 | HardwareSerial_write('.'); 35 | HardwareSerial_write(HardwareSerial_read()); 36 | }; 37 | 38 | for (i=60000; i; i--); 39 | } 40 | -------------------------------------------------------------------------------- /test/serialEvent/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../sduino/stm8/sduino.mk 4 | -------------------------------------------------------------------------------- /test/serialEvent/serialEvent.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test serialEvent() 3 | * 4 | * Read data from the serial interface an echo it back using the serialEvent() 5 | * function. 6 | * 7 | * written Sep. 2017 by Michael Mayer for the SDuino project 8 | * Code is in the public domain. 9 | */ 10 | 11 | #include "Arduino.h" 12 | 13 | 14 | void setup(void) 15 | { 16 | Serial_begin(9600); 17 | Serial_println_s("Hello World!"); 18 | } 19 | 20 | 21 | void loop (void) 22 | { 23 | } 24 | 25 | void serialEvent(void) 26 | { 27 | while(HardwareSerial_available()) { 28 | Serial_write(Serial_read()); 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /test/spi/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../sduino/stm8/sduino.mk 4 | -------------------------------------------------------------------------------- /test/spi/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/ 15 | # -DSUPPORT_ALTERNATE_MAPPINGS 16 | 17 | LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103 18 | 19 | OBJECTS=$(BASENAME).rel 20 | SDOBJECTS=main.rel wiring.rel wiring_digital.rel SPI.rel \ 21 | HardwareSerial.rel Print.rel 22 | 23 | .PHONY: all clean flash 24 | 25 | #all: $(OBJECTS) 26 | 27 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 28 | #test.rel wiring_digital.rel 29 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 30 | 31 | $(OBJECTS) : %.rel : %.c 32 | $(CC) -c $(CFLAGS) $^ -o $@ 33 | 34 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 35 | $(CC) -c $(CFLAGS) $^ -o $@ 36 | 37 | flash: $(EXECUTABLE) 38 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 39 | 40 | readopt: 41 | stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin 42 | 43 | 44 | clean: 45 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 46 | *.cdb *.adb *~ *.bak 47 | rm -f $(EXECUTABLE) 48 | -------------------------------------------------------------------------------- /test/spi/spi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test spi functions 3 | */ 4 | 5 | #include "Arduino.h" 6 | #include "SPI.h" 7 | #include "Serial.h" 8 | 9 | // pin number for the status LED 10 | #define LED 3 11 | 12 | /* 13 | // 9 PC7 MISO 14 | // 8 PC6 MOSI 15 | // 7 PC5 SCK 16 | // 3 PB5 LED/SS 17 | */ 18 | 19 | //const char testdata[]="ABCDEFGH"; 20 | const char testdata[]="UUUUUUUU"; // regular bit pattern 01010101 21 | char buf[16]; 22 | 23 | uint8_t ledstatus; 24 | 25 | /* 26 | * simple test using single byte transfers 27 | */ 28 | void SPI_transfer_loop(uint8_t *buf, size_t n) 29 | { 30 | while (--n) { 31 | *buf = SPI_transfer(*buf); 32 | buf++; 33 | } 34 | } 35 | 36 | 37 | void setup(void) 38 | { 39 | pinMode(LED, OUTPUT); 40 | Serial_begin(115200); 41 | Serial_println_s("SPI test"); 42 | } 43 | 44 | 45 | void loop (void) 46 | { 47 | uint8_t i; 48 | 49 | Serial_println_s("loop"); 50 | strcpy(buf, testdata); 51 | delay(100); 52 | 53 | digitalWrite(LED,1);//ledstatus); 54 | ledstatus = 1-ledstatus; 55 | 56 | 57 | SPI_begin(); 58 | SPI_beginTransaction(SPISettings(8000000L,MSBFIRST,SPI_MODE0)); 59 | Serial_print_c('a'); 60 | // SPI_transfer(0xaa); 61 | // SPI_transfer(0x55); 62 | Serial_print_c('b'); 63 | 64 | SPI_transfer_asm(buf, sizeof(testdata)-1); 65 | SPI_endTransaction(); 66 | Serial_print_c('c'); 67 | SPI_end(); 68 | Serial_print_c('d'); 69 | 70 | digitalWrite(LED,0); 71 | 72 | for (i=0; i<8; i++) { 73 | Serial_print_ub(buf[i],HEX); 74 | Serial_print_c(' '); 75 | } 76 | 77 | delay(100); 78 | } 79 | -------------------------------------------------------------------------------- /test/timer1/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../sduino/stm8/sduino.mk 4 | -------------------------------------------------------------------------------- /test/timer1/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/ 15 | 16 | LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s 17 | 18 | OBJECTS=$(BASENAME).rel 19 | SDOBJECTS=main.rel wiring.rel HardwareSerial.rel Print.rel 20 | 21 | .PHONY: all clean flash 22 | 23 | #all: $(OBJECTS) 24 | 25 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 26 | #test.rel wiring_digital.rel 27 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 28 | 29 | $(OBJECTS) : %.rel : %.c 30 | $(CC) -c $(CFLAGS) $^ -o $@ 31 | 32 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 33 | $(CC) -c $(CFLAGS) $^ -o $@ 34 | 35 | flash: $(EXECUTABLE) 36 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 37 | 38 | 39 | clean: 40 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 41 | *.cdb *.adb *~ *.bak 42 | rm -f $(EXECUTABLE) 43 | -------------------------------------------------------------------------------- /test/timer1/timer1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test timer4, show the value for millis() over time 3 | */ 4 | 5 | #include "Arduino.h" 6 | #include "Serial.h" 7 | 8 | 9 | void setup(void) 10 | { 11 | Serial_begin(115200); 12 | } 13 | 14 | 15 | void loop (void) 16 | { 17 | uint32_t i; 18 | 19 | Serial_print_s("millis()="); 20 | Serial_print_u(millis()); 21 | Serial_print_s("\tTIM4_CNTR="); 22 | Serial_println_u(TIM4->CNTR); 23 | 24 | for (i=40000; i; i--); 25 | } 26 | -------------------------------------------------------------------------------- /test/timer2/Makefile: -------------------------------------------------------------------------------- 1 | BOARD_TAG = stm8sblue 2 | 3 | include ../../sduino/stm8/sduino.mk 4 | -------------------------------------------------------------------------------- /test/timer2/Makefile.classic: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/ 15 | 16 | LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s 17 | 18 | OBJECTS=$(BASENAME).rel 19 | SDOBJECTS=main.rel wiring.rel HardwareSerial.rel Print.rel 20 | 21 | .PHONY: all clean flash 22 | 23 | #all: $(OBJECTS) 24 | 25 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 26 | #test.rel wiring_digital.rel 27 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 28 | 29 | $(OBJECTS) : %.rel : %.c 30 | $(CC) -c $(CFLAGS) $^ -o $@ 31 | 32 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 33 | $(CC) -c $(CFLAGS) $^ -o $@ 34 | 35 | flash: $(EXECUTABLE) 36 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 37 | 38 | 39 | clean: 40 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 41 | *.cdb *.adb *~ *.bak 42 | rm -f $(EXECUTABLE) 43 | -------------------------------------------------------------------------------- /test/uart-nospl/Makefile: -------------------------------------------------------------------------------- 1 | BASENAME=$(shell basename $$(pwd)) 2 | EXECUTABLE=$(BASENAME).ihx 3 | 4 | #SDCCBASE=/usr/local 5 | SDCCBASE=/opt/sdcc 6 | BINDIR=$(SDCCBASE)/bin 7 | CC=$(BINDIR)/sdcc 8 | LD=$(BINDIR)/sdld 9 | 10 | LIBBASE=../../sduino/stm8/STM8S_StdPeriph_Driver 11 | SDUINO=../../sduino 12 | 13 | CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 -DSUPPORT_ALTERNATE_MAPPINGS \ 14 | -I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/ 15 | 16 | LDFLAGS=-L$(LIBBASE)/lib -L$(SDCCBASE)/share/sdcc/lib/stm8 -lSTM8S103 17 | 18 | OBJECTS=$(BASENAME).rel 19 | SDOBJECTS= 20 | # main.rel wiring.rel wiring_digital.rel wiring_analog.rel \ 21 | # HardwareSerial.rel Print.rel 22 | 23 | .PHONY: all clean flash 24 | 25 | #all: $(OBJECTS) 26 | 27 | $(EXECUTABLE): $(OBJECTS) $(SDOBJECTS) 28 | #test.rel wiring_digital.rel 29 | $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ 30 | 31 | $(OBJECTS) : %.rel : %.c 32 | $(CC) -c $(CFLAGS) $^ -o $@ 33 | 34 | $(SDOBJECTS) : %.rel : $(SDUINO)/%.c 35 | $(CC) -c $(CFLAGS) $^ -o $@ 36 | 37 | flash: $(EXECUTABLE) 38 | stm8flash -cstlinkv2 -pstm8s103?3 -w $^ 39 | 40 | readopt: 41 | stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin 42 | 43 | 44 | clean: 45 | rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \ 46 | *.cdb *.adb *~ *.bak 47 | rm -f $(EXECUTABLE) 48 | -------------------------------------------------------------------------------- /test/uart-nospl/uart-nospl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * using the UART1 without any SPL functions. 5 | * 6 | * simple testbed to test the simplified initialization function. 7 | * 8 | */ 9 | 10 | #define UART1_CR2_RIEN 0x20 11 | #define UART1_TEN 0x08 12 | #define UART1_REN 0x04 13 | 14 | unsigned char 15 | UART1_BRR1, 16 | UART1_BRR2, 17 | UART1_CR1, 18 | UART1_CR2, 19 | UART1_CR3; 20 | 21 | 22 | unsigned long CLK_GetClockFreq(void) 23 | { 24 | return 10000000UL; 25 | } 26 | 27 | 28 | void HardwareSerial_begin(unsigned long baud) 29 | { 30 | uint16_t divider; 31 | uint8_t tmp; 32 | 33 | /* Set the UART1 BaudRates in BRR1 and BRR2 registers according to UART1_BaudRate value */ 34 | divider = (uint16_t) ((uint32_t)CLK_GetClockFreq() / (uint32_t) baud); 35 | 36 | UART1_BRR2 = divider & 0x0f; 37 | divider >>= 4; 38 | UART1_BRR1 = divider & 0xff; 39 | divider >>= 4; 40 | UART1_BRR2 |= (uint8_t) divider & 0xf0; 41 | 42 | UART1_CR1 = 0; // 8 Bit, no parity 43 | UART1_CR3 = 0; // one stop bit 44 | // enable RXNE interrupt, enable transmitter, enable receiver 45 | UART1_CR2 = UART1_CR2_RIEN | UART1_TEN | UART1_REN; 46 | } 47 | 48 | 49 | void main (void) 50 | { 51 | HardwareSerial_begin(9600); 52 | } 53 | -------------------------------------------------------------------------------- /test/valist/Makefile: -------------------------------------------------------------------------------- 1 | CC=sdcc 2 | CFLAGS=-mstm8 -I /opt/sdcc/share/sdcc/include 3 | 4 | main: 5 | -------------------------------------------------------------------------------- /test/valist/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | //#include 3 | 4 | int a_function ( int x, ... ) 5 | { 6 | va_list a_list; 7 | int sum=0; 8 | 9 | va_start( a_list, x ); 10 | 11 | while (x--) sum += va_arg(a_list, int); 12 | 13 | return sum; 14 | } 15 | 16 | void main() 17 | { 18 | a_function(2, 11,22); 19 | a_function(3, 11,22,33); 20 | } 21 | -------------------------------------------------------------------------------- /tools/.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | -------------------------------------------------------------------------------- /tools/format_examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/dash 2 | 3 | # a simple script to convert the example sketches into valid *.md listings 4 | # ready to be used in the documentation. 5 | 6 | for i in *; do 7 | (echo "# $i.ino"; echo '```c'; cat $i/$i.ino; echo '```') > $i.md; 8 | done 9 | -------------------------------------------------------------------------------- /tools/lib/windows/libusb-1.0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tenbaht/sduino/0ce7e4c381028f6472eb29e8459210cee90b937d/tools/lib/windows/libusb-1.0.dll -------------------------------------------------------------------------------- /tools/sdcc-critcal.patch: -------------------------------------------------------------------------------- 1 | --- sdcc/src/stm8/gen.c.orig 2016-10-23 19:12:25.000000000 +0200 2 | +++ sdcc/src/stm8/gen.c 2016-12-13 15:27:19.756097765 +0100 3 | @@ -2980,6 +2980,7 @@ 4 | static void 5 | genCritical (iCode * ic) 6 | { 7 | + emit2("push cc", ""); 8 | emit2("sim", ""); 9 | cost (1, 1); 10 | } 11 | @@ -2987,7 +2988,7 @@ 12 | static void 13 | genEndCritical (iCode * ic) 14 | { 15 | - emit2("rim", ""); 16 | + emit2("pop cc", ""); 17 | cost (1, 1); 18 | } 19 | 20 | --------------------------------------------------------------------------------