Skip to content

Commit e6e0061

Browse files
committed
added usage example in README
1 parent e6320ce commit e6e0061

4 files changed

Lines changed: 68 additions & 19 deletions

File tree

README.md

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,60 @@ for others as well. The documentation is incomplete and written in a wild
2727
mix of English and German, but hopefully you can still figure it out.
2828

2929

30+
## Usage
31+
32+
If you have ever used the Arduino environment before you will feel at home
33+
right away. The compilation is controlled by a makefile based on the amazing
34+
[Arduino.mk makefile](https://github.com/sudar/Arduino-Makefile) by
35+
[Sudar](http://sudarmuthu.com>).
36+
37+
Let's blink an LED using the Blink example from Arduino:
38+
39+
```
40+
/*
41+
Blink
42+
Turns on an LED on for one second, then off for one second, repeatedly.
43+
44+
This example code is in the public domain.
45+
*/
46+
47+
#include <Arduino.h>
48+
49+
// Pin 13 has an LED connected on most Arduino boards.
50+
// Pin 3 for the STM8S103 break out board
51+
// give it a name:
52+
int led = PIN_LED_BUILDIN;
53+
54+
// the setup routine runs once when you press reset:
55+
void setup() {
56+
// initialize the digital pin as an output.
57+
pinMode(led, OUTPUT);
58+
}
59+
60+
// the loop routine runs over and over again forever:
61+
void loop() {
62+
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
63+
delay(1000); // wait for a second
64+
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
65+
delay(1000); // wait for a second
66+
}
67+
```
68+
69+
All we need for a full build is this very basic `Makefile`:
70+
71+
```
72+
BOARD_TAG = stm8sblue
73+
74+
include ../../sduino/sduino.mk
75+
```
76+
77+
Compile and upload it:
78+
79+
make upload
80+
81+
Done! Your first STM8 based project is up and running!
82+
83+
3084

3185
## Tools used
3286

@@ -39,9 +93,9 @@ SDCC support for the STM8 is still quite fresh and not very mature. It
3993
improves significantly from version to version. Be sure to use
4094
[the latest snapshot build](http://sdcc.sourceforge.net/snap.php) from the
4195
[project site on sourceforge](http://sdcc.sourceforge.net/), not the older
42-
version that might be included in your distribution. Version 3.5.0 as included with
43-
ubuntu 16.04 is definitly too old and compilation will fail due to some
44-
compiler errors.
96+
version that might be included in your distribution. Version 3.5.0 as
97+
included with ubuntu 16.04 is definitly too old and compilation will fail
98+
due to some compiler errors.
4599

46100
Support for the Cosmic compiler under Windows and integration into the ST
47101
visual developer IDE might be possible, but is not done (yet?).
@@ -112,27 +166,22 @@ an option.
112166

113167

114168

115-
## Usage
116-
117-
No real documentation yet. Have a look in the `test` directory and use one of the Makefiles as a template.
118-
119-
120169
## Included libraries
121170

122-
**I2C**: The [I2C master library]
123-
(http://www.dsscircuits.com/articles/arduino-i2c-master-library)
171+
**I2C**: The
172+
[I2C master library] (http://www.dsscircuits.com/articles/arduino-i2c-master-library)
124173
by Wayne Truchsess offers some significant advantages over the Wire/TWI
125174
library included in the standard arduino environment: It fixes some possible
126175
deadlock situations, it allows for communication using a repeated start
127176
condition as required by some devices, the code is much more compact and the
128177
structure is easier to understand.
129178

130-
So I decided to port this library instead of the standard one. the current
131-
state does not include the deadlock protection, though.
179+
The current state of the port does not include the deadlock protection,
180+
though.
132181

133182

134183
**ssd1306**: Driver for SSD1306-based monochrome OLED display with 128x64
135-
pixels. Based on the Adafruit-libray.
184+
pixels. I2C support only. Based on the Adafruit-libray.
136185

137186

138187
## Why use a STM8 instead of an ATmega?

sduino/Arduino.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ endif
867867
ifeq ($(strip $(NO_CORE)),)
868868
ifndef MONITOR_BAUDRATE
869869
ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1)
870-
SPEED = $(shell egrep -h 'Serial.begin *\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1)
870+
SPEED = $(shell egrep -h 'Serial[._]begin *\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1)
871871
MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200)
872872
endif
873873

sduino/pins_arduino.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ static const uint8_t SCL = PIN_WIRE_SCL;
115115
#define SDA PIN_WIRE_SDA
116116
#define SCL PIN_WIRE_SCL
117117

118-
#define LED_BUILTIN (PB5) // 3
119-
#define TX_PIN (PD5) // sduino: pin for TX line
120-
#define RX_PIN (PD6) // sduino: pin for RX line
118+
#define PIN_LED_BUILTIN (PB5) // sduino: pin for the buildin LED, pin 3
119+
#define PIN_TX (PD5) // sduino: pin for TX line
120+
#define PIN_RX (PD6) // sduino: pin for RX line
121121

122122
#define PIN_A0 (PC4) // 6, Ain2
123123
#define PIN_A1 (PD2) // 11, Ain3

sduino/sduino.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ endif
4242
ARDUINO_SKETCHBOOK = /tmp # temporarly, to prevent usage of the real libs
4343
ARDMK_VENDOR = sduino
4444
ARCHITECTURE = stm8
45-
CPPFLAGS = -DSTM8S103 -I$(ARDUINO_DIR)/../STM8S_StdPeriph_Driver/inc -I/opt/sdcc/share/sdcc/include/
45+
CPPFLAGS += -DSTM8S103 -I. -I$(ARDUINO_DIR)/../STM8S_StdPeriph_Driver/inc -I/opt/sdcc/share/sdcc/include/
4646
#CFLAGS = -I ../STM8S_StdPeriph_Driver/inc
4747
#LDFLAGS = --out-fmt-elf
48-
LDFLAGS = -L $(ARDUINO_DIR)/../STM8S_StdPeriph_Driver/src -L/opt/sdcc/share/sdcc/lib/stm8
48+
LDFLAGS += -L $(ARDUINO_DIR)/../STM8S_StdPeriph_Driver/src -L/opt/sdcc/share/sdcc/lib/stm8
4949

5050

5151

0 commit comments

Comments
 (0)