Skip to content

Commit 97eae2f

Browse files
committed
add support for STM8S-Discovery from ST
1 parent 2fa35dc commit 97eae2f

13 files changed

Lines changed: 620 additions & 89 deletions

File tree

docs/hardware/esp14.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ is clearly one of the cheapest CPUs on the market, but the applications for
7171
this module are heavily restricted the the small flash memory.
7272

7373
Why didn't they use an ATmega328? Just one dollar more and the whole Arduino
74-
universe opens up? Or at least an STM8S005K6T6C, offering 32kB flash and 2kB
74+
universe opens up. Or at least an STM8S005K6T6C, offering 32kB flash and 2kB
7575
RAM for only 40 cents more, if you want to go really cheap.
7676

77-
And why would you need an additional PMOS to control the ESP power supply?
77+
And why would you need an external PMOS to control the ESP power supply?
7878
Why is this not included on the PCB already? This could the big killer
7979
feature of the current combination.
8080

docs/hardware/stm8disco.md

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
# STM8S Discovery
22

3+
A widespread evaluation board made by ST. All CPU pin are easily accessible
4+
on 2x6 pin headers. It costs only $9 and includes a ST-Link/v1 flash
5+
programmer on board.
6+
7+
It should work now, but the support is very fresh and not thoroughly tested.
8+
At least Blink.c is known to work already.
9+
310
STM8S105C6T6 microcontroller, 32 KB Flash, 2 KB RAM, 1 KB EEPROM
411

512
- LED on PD0, active low.
613
- Touch button on PC1, PC2.
7-
- external cristal 16MHz on PA1/PA2
14+
- external crystal 16MHz on PA1/PA2
815

916

1017

@@ -23,26 +30,37 @@ Pin | Signal
2330
## Usage with Linux and stm8flash
2431

2532
The discovery board implements two USB devices: A ST-LINK/V1 interface and a
26-
(not very useful) mass storage device with some links to the ST website.
27-
The implementation of this mass storage device is very buggy and renders the
33+
(not very useful) mass storage device with some links to the ST website. The
34+
implementation of this mass storage device is very buggy and renders the
2835
hole board useless. You need to make modprobe to ignore it by adding this
2936
line to /etc/modprobe.conf or by adding a file
3037
/etc/modprobe.d/stdiscovery.conf with this line:
3138

3239
options usb-storage quirks=0483:3744:i
3340

34-
Unplug the Discovery board, unload the usb mass storage driver with
41+
Unplug the Discovery board and unload the usb mass storage driver with
3542

3643
modprobe -r uas usb_storage
3744

38-
and reconnect the board. If you can't unload the usb_storage drive because
39-
it is in use with other devices you can temporary trigger the same effect by
40-
this line:
45+
If you can't unload the usb_storage drive because it is in use with other
46+
devices you can temporary trigger the same effect by this line:
4147

4248
echo "0483:3744:i" >/sys/module/usb_storage/parameters/quirks
4349

44-
Now dmesg should show that the mass storage device of the Discovery board is
45-
ignored:
50+
The second step is to add a new udev rule in order to access the USB port.
51+
Save this as root in in `/etc/udev/rules.d/99-stlink.rules`:
52+
53+
# ST-Link/V2 programming adapter
54+
55+
# ST-Link V1, if using a STM8S discovery board
56+
# important: It needs a special entry in /etc/modprob/blacklist
57+
ATTR{idVendor}=="0483", ATTR{idProduct}=="3744", MODE="0666", GROUP="plugdev"
58+
59+
# ST-Link/V2, the china adapter with the green plastic housing
60+
ATTR{idVendor}=="0483", ATTR{idProduct}=="3748", MODE="0666", GROUP="plugdev"
61+
62+
Finally, it is time to (re-) connect the board. Now dmesg should show that
63+
the mass storage device of the Discovery board is ignored:
4664

4765
[ 815.228928] usbcore: deregistering interface driver uas
4866
[ 815.229201] usbcore: deregistering interface driver usb-storage

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ with github pages and the preinstalled jekyll-themes?)
5050
4. [Supported Boards](hardware.md)
5151
* [stm8blue: simple breakout board, STM8S103](hardware/stm8blue.md)
5252
* [ESP14: Wifi board, STM8S003](hardware/esp14.md)
53-
* [STM8S105Discovery: Evaluation board made my ST](hardware/stm8disco.md)
53+
* [STM8S105Discovery: Evaluation board made my ST](hardware/stm8discovery.md)
5454
5. [Ways to define a pin mapping](pin_mapping.md)
5555
6. [Using the SDCC compiler](sdcc.md)
5656
7. [Using the SPL with SDCC and sduino](spl.md)

sduino/examples/01.Basics/Blink/Blink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Pin 13 has an LED connected on most Arduino boards.
1111
// Pin 3 for the STM8S103 break out board
1212
// give it a name:
13-
int led = 3;
13+
int led = LED_BUILDIN;
1414

1515
// the setup routine runs once when you press reset:
1616
void setup() {

sduino/hardware/sduino/stm8/boards.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ stm8sblue.upload.speed=1
2424
stm8sdisco.name=STM8S105C6 Discovery Board
2525

2626
stm8sdisco.upload.using=stm8flash
27-
stm8sdisco.upload.protocol=stlinkv2
27+
stm8sdisco.upload.protocol=stlink
2828
stm8sdisco.upload.mcu=stm8s105?6
2929
stm8sdisco.upload.maximum_size=32768
3030

sduino/hardware/sduino/stm8/cores/sduino/Arduino.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ void alternateFunction(uint8_t val);
257257
#define TIMER21 5
258258
#define TIMER22 6
259259
#define TIMER23 7
260+
#define TIMER31 8
261+
#define TIMER32 9
260262

261263

262264
//FIXME#include "WCharacter.h"
@@ -288,14 +290,15 @@ inline unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8)
288290
* The new interrupt numbers are a combination of the position in the
289291
* internal jump table (value in LSB) and the real STM8S-Interrupt number (MSB)
290292
*/
291-
#define INT_PORTA (0 | (uint16_t)(ITC_IRQ_PORTA << 8))
292-
#define INT_PORTB (1 | (uint16_t)(ITC_IRQ_PORTB << 8))
293-
#define INT_PORTC (2 | (uint16_t)(ITC_IRQ_PORTC << 8))
294-
#define INT_PORTD (3 | (uint16_t)(ITC_IRQ_PORTD << 8))
295-
#define INT_TIM1_CAPCOM (4 | (uint16_t)(ITC_IRQ_TIM1_CAPCOM << 8))
296-
#define INT_TIM1_OVF (5 | (uint16_t)(ITC_IRQ_TIM1_OVF << 8))
297-
#define INT_TIM2_CAPCOM (6 | (uint16_t)(ITC_IRQ_TIM2_CAPCOM << 8))
298-
#define INT_TIM2_OVF (7 | (uint16_t)(ITC_IRQ_TIM2_OVF << 8))
293+
#define INT_PORTA ( 0| (uint16_t)(ITC_IRQ_PORTA << 8))
294+
#define INT_PORTB ( 1| (uint16_t)(ITC_IRQ_PORTB << 8))
295+
#define INT_PORTC ( 2| (uint16_t)(ITC_IRQ_PORTC << 8))
296+
#define INT_PORTD ( 3| (uint16_t)(ITC_IRQ_PORTD << 8))
297+
#define INT_PORTE ( 4| (uint16_t)(ITC_IRQ_PORTE << 8))
298+
#define INT_TIM1_CAPCOM ( 5| (uint16_t)(ITC_IRQ_TIM1_CAPCOM << 8))
299+
#define INT_TIM1_OVF ( 6| (uint16_t)(ITC_IRQ_TIM1_OVF << 8))
300+
#define INT_TIM2_CAPCOM ( 7| (uint16_t)(ITC_IRQ_TIM2_CAPCOM << 8))
301+
#define INT_TIM2_OVF ( 8| (uint16_t)(ITC_IRQ_TIM2_OVF << 8))
299302

300303

301304

0 commit comments

Comments
 (0)